function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mangiamangia 

Error calling my .NET web service from Apex code

I am trying to call my .NET web service from Apex code and would like 
some help and advise (I a newbie ;)
I added my web service URL in
the
Remote Site Settings area and generated an Apex Code object from my WSDL.
I created an S-Control to call my Apex Code and it fails. When I copied the Apex
code into Apex Log Debug window and Execute, I receive the follow error. Any clues?
I suspect my WSDL or generated an Apex Code object from my WSDL is at fault.
Any links or example references (beyond Hello World) would be great too!


Chris




13:39:21 DEBUG - Executing: SymphonieApiWs.SymphonieWsSoap api = new SymphonieApiWs.SymphonieWsSoap();
SymphonieApiWs.LoginResult loginInfo = api.Login('customer', 'login', 'pw');
13:39:21 DEBUG - Executing: SymphonieApiWs.SymphonieWsSoap api = new SymphonieApiWs.SymphonieWsSoap();
SymphonieApiWs.LoginResult loginInfo = api.Login('customer', 'login', 'pw');
13:39:23 INFO  - 20070830203922.736:Class.SymphonieApiWs.SymphonieWsSoap.Login: line 296, column 13: 
Created Web Service callout to endpoint: https://symphonie.goolara.net/Api/SymphonieApiWs.asmx 20070830203922.736:Class.SymphonieApiWs.SymphonieWsSoap.Login: line 296, column 13:
Sending callout request System.CalloutException: Web service callout failed: Unauthorized or inactive endpoint, please
check Setup->Security->Remote site settings.
endpoint = https://symphonie.goolara.net/Api/SymphonieApiWs.asmx Class.SymphonieApiWs.SymphonieWsSoap.Login: line 296, column 13 AnonymousBlock: line 2, column 40
13:39:23 INFO - 20070830203922.736:Class.SymphonieApiWs.SymphonieWsSoap.Login: line 296, column 13:
Created Web Service callout to endpoint:
https://symphonie.goolara.net/Api/SymphonieApiWs.asmx 20070830203922.736:Class.SymphonieApiWs.SymphonieWsSoap.
Login: line 296, column 13: Sending callout request System.CalloutException: Web service callout failed:
Unauthorized or inactive endpoint, please check Setup->Security->Remote site settings.
endpoint = https://symphonie.goolara.net/Api/SymphonieApiWs.asmx Class.SymphonieApiWs.SymphonieWsSoap.Login:
line 296, column 13 AnonymousBlock: line 2, column 40
13:39:23 ERROR - Evaluation error: System.CalloutException: Web service callout failed: 
Unauthorized or inactive endpoint, please check Setup->Security->Remote site settings.
endpoint = https://symphonie.goolara.net/Api/SymphonieApiWs.asmx
13:39:23 ERROR - Evaluation error: System.CalloutException: Web service callout failed: Unauthorized
or inactive endpoint, please check Setup->Security->Remote site settings.
endpoint = https://symphonie.goolara.net/Api/SymphonieApiWs.asmx
13:39:23 ERROR - Evaluation error: Class.SymphonieApiWs.SymphonieWsSoap.Login: line 296, column 13
   AnonymousBlock: line 2, column 40
SuperfellSuperfell
Are you sure you specified https when you created the entry in the remote sites setting ?
mangiamangia
Yes, I have tried both http: and https:
mangiamangia
From the error message, it seems some part of the WSDL response definition 
is errorant? If my web service supports both 'soap' and 'soap12' will that
cause this type of problem?
16:13:21 ERROR - Evaluation error: System.CalloutException: Web service 
callout failed: Unexpected element. Parser was expecting element
'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'
Chris
SuperfellSuperfell
Typically what happens is the call goes to your server, but that has some kind of unhandled exception, and so the server returns an HTML error page.
sraghusraghu
Hi,
 
we are running into the same issue:
The Error message is
{faultcode:'soapenv:Client', faultstring:'System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'
 
Any suggestions on this, will be appreciable.
 
Thanks in Advance.
 
 
 
mangiamangia

The WSDL I had generated via VS.NET included bindings for both 'soap' and 'soap12'.  SalesForce ONLY wants 'soap', so I had to modify the WSDL to eliminate the Soap12 bindings. 

 

balajir74balajir74
I am facing the same issue , were you guys able to resolve this issue.
mangiamangia
Yes we did.

The WSDL generated by VS.NET includes bindings for BOTH 'soap' and 'soap12'.

SalesForce ONLY wants 'soap', so I had to modify the WSDL to eliminate the Soap12 bindings. (Near the end of the file)

Chris
balajir74balajir74
I did that , only after that i was able to generate the Apex class. The following is the class i generated from wsdl. //Generated by wsdl2apex public class tempuriOrg { public class ValidateZipCode_element { public String vZipCode; public String vBusinessLine; private String[] vZipCode_type_info = new String[]{'vZipCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] vBusinessLine_type_info = new String[]{'vBusinessLine','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'}; private String[] field_order_type_info = new String[]{'vZipCode','vBusinessLine'}; } public class HeraServiceSoap { public String endpoint_x = 'http://cscrdwuvd106/HeraService/HeraService.asmx'; private String[] ns_map_type_info = new String[]{'http://tempuri.org/', 'tempuriOrg'}; public Boolean ValidateZipCode(String vZipCode,String vBusinessLine) { tempuriOrg.ValidateZipCode_element request_x = new tempuriOrg.ValidateZipCode_element(); tempuriOrg.ValidateZipCodeResponse_element response_x; request_x.vZipCode = vZipCode; request_x.vBusinessLine = vBusinessLine; Map response_map_x = new Map(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://tempuri.org/ValidateZipCode', 'http://tempuri.org/', 'ValidateZipCode', 'http://tempuri.org/', 'ValidateZipCodeResponse', 'tempuriOrg.ValidateZipCodeResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.ValidateZipCodeResult; } } public class ValidateZipCodeResponse_element { public Boolean ValidateZipCodeResult; private String[] ValidateZipCodeResult_type_info = new String[]{'ValidateZipCodeResult','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'}; private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'}; private String[] field_order_type_info = new String[]{'ValidateZipCodeResult'}; } } I am still getting the same error Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html' Any ideas
SuperfellSuperfell
Yes, your web service should be returning a SOAP envelope tag, but it didn't it returned an element called html instead.

Typically what happens is the call goes to your server, but that has some kind of unhandled exception, and so the server returns an HTML error page, instead of a SOAP message.

Cheers
Simon