You need to sign in to do that
Don't have an account?
sd2008
'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'
my apex class method is trying to call an external webservice function, and it gives this
Failed to invoke future method 'public static void mycall()'
Debug Log:
System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'
Debug Log:
System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'
any idea of how to fix this? what should I do to make it work?
thanks for reply,
so I need to modify the firewall on the server?
Hi SimonF
My webservice function running fine, I tested it on localhost and on the server. it only returns a string after each call.
could that mean the error message is from a firewall or proxy? if that is the case, how should I fix it?
When I've run into similar Callout issues in the past, I have used the Execute Anonymous functionality of the Force.com IDE. Its one of the Eclipse views. In that view, you can output the Callout SOAP request and response messages. So in the Execute Anonymous perspective, build a simple test case to invoke the callout and check the debug output for the SOAP msgs.
The debugging leverages the Execute Anonymous view within the Force.com IDE. So to start, open up the Execute Anonymous view in the IDE, write a test case in Apex code in the dialog window. At a minimum, the test case should prepare the test data required to invoke the Apex method that performs the callout.The test case needs to prepare the apex classes and relevant variables needed to call the apex method that does the callout.
Next, when the test case is ready to be executed, click the 'Execute Anonymous' button and the Results panel below will be populated with the results, including the Callout details.
So using a combination of the Force.com IDE, Execute Anonymous view, and writing test cases to invoke the Apex callout, you can output the actual SOAP XML messages to help assist with debugging and troubleshooting.
To specifically answer your question - you don't need to write a "program". But you do need to write apex instantiating the necessary objects, setting the proper variables required to initiate the apex method that performs the callout. So its more of a small test case than a program.
thanks
I am working on it.
DEBUG LOG
20090115183819.984:Class.WS3.ServiceSoap.TestRun: line 81, column 13: Created Web Service callout to endpoint: http://********/********/Service.asmx
20090115183819.984:Class.WS3.ServiceSoap.TestRun: line 81, column 13: Sending callout request
20090115183819.984:Class.WS3.ServiceSoap.TestRun: line 81, column 13: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header /><env:Body><TestRun xmlns="http://tempuri.org/" /></env:Body></env:Envelope>
20090115183819.984:Class.WS3.ServiceSoap.TestRun: line 81, column 13: Reading callout response
20090115183819.984:Class.WS3.ServiceSoap.TestRun: line 81, column 13: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>502 Proxy Error</title>
</head><body>
<h1>Proxy Error</h1>
<p>The proxy server received an invalid
response from an upstream server.<br />
The proxy server could not handle the request <em><a href="http://cas-ds2/CasAssocOrigination_Project/Service.asmx">POST http://cas-ds2/CasAssocOrigination_Project/Service.asmx</a></em>.<p>
Reason: <strong>DNS lookup failure for: cas-ds2</strong></p></p>
</body></html>
System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'
Class.WS3.ServiceSoap.TestRun: line 81, column 13
AnonymousBlock: line 3, column 19
It can't work out what the IP address is for the URL used, because you're using names that are private to your local network, and not globally resolvable names.
how did you manage to out put call out requests and responces when i execute anonymous i get this
20090901073359.142:Class.Customers.CustomersSoap.AddCustomer: line 87, column 13: Created Web Service callout to endpoint: http://*****
20090901073359.142:Class.Customers.CustomersSoap.AddCustomer: line 87, column 13: Sending callout request
20090901073359.142:Class.Customers.CustomersSoap.AddCustomer: line 87, column 13: Reading callout response
20090901073359.142:Class.Ext_Webservice.Call_Odin_Webservice: line 122, column 9: DeclareVar: Integer i
20090901073359.142:Class.Ext_Webservice.Call_Odin_Webservice: line 122, column 9: initial value: 1
can you please help me out
I tried to use the anonymous execution - but could not see the resulting callout response. Just, the ':HTML' received message. Can someone post a complete example?
Any help would be really appreciated!
Anonymous Execute as well as the Debug Messages on the Salesforce-Setup-Pages show only:
Anonymous execution was successful.20090923085336.679:AnonymousBlock: line 1, column 1: Anonymous20090923085336.679:AnonymousBlock: line 1, column 1: DeclareVar: schemasMicrosoftComSharepointSoapDw DwsService20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 3, column 8: Static initialization: schemasMicrosoftComSharepointSoapDw20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 3, column 8: Entering user sharing mode20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 3, column 8: Exiting user sharing mode20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 3, column 14: Instance initialization: schemasMicrosoftComSharepointSoapDw20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 3, column 14: Entering user sharing mode20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 3, column 14: Exiting user sharing mode20090923085336.679:AnonymousBlock: line 1, column 1: initial value: schemasMicrosoftComSharepointSoapDw:[]20090923085336.679:AnonymousBlock: line 2, column 1: DeclareVar: schemasMicrosoftComSharepointSoapDw.DwsSoap dwssoap20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 100, column 18: Instance initialization: DwsSoap20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 100, column 18: Entering user sharing mode20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 101, column 16: DeclareVar: public String endpoint_x20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 101, column 16: initial value: http://mydomain.de/_vti_bin/DWS.asmx20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 102, column 16: DeclareVar: public MAP:String,String inputHttpHeaders_x20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 103, column 16: DeclareVar: public MAP:String,String outputHttpHeaders_x20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 104, column 16: DeclareVar: public String clientCert_x20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 105, column 16: DeclareVar: public String clientCertPasswd_x20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 106, column 16: DeclareVar: public Integer timeout_x20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 107, column 17: DeclareVar: private LIST:String ns_map_type_info20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 107, column 17: initial value: (http://schemas.microsoft.com/sharepoint/soap/dws/, schemasMicrosoftComSharepointSoapDw)20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 100, column 18: Exiting user sharing mode20090923085336.679:AnonymousBlock: line 2, column 1: initial value: schemasMicrosoftComSharepointSoapDw.DwsSoap:[clientCertPasswd_x=null, clientCert_x=null, endpoint_x=http://mydomain.de/_vti_bin/DWS.asmx, inputHttpHeaders_x=null, ns_map_type_info=(http://schemas.microsoft.com/sharepoint/soap/dws/, schemasMicrosoftComSharepointSoapDw), outputHttpHeaders_x=null, timeout_x=null]20090923085336.679:AnonymousBlock: line 6, column 1: DeclareVar: String username20090923085336.679:AnonymousBlock: line 6, column 1: initial value: username20090923085336.679:AnonymousBlock: line 7, column 1: DeclareVar: String password20090923085336.679:AnonymousBlock: line 7, column 1: initial value: passwd20090923085336.679:AnonymousBlock: line 9, column 1: DeclareVar: Blob headerValue20090923085336.679:AnonymousBlock: line 9, column 1: initial value: Blob[15]20090923085336.679:AnonymousBlock: line 10, column 1: schemasMicrosoftComSharepointSoapDw.DwsSoap dwssoap.inputHttpHeaders_x <= NewMap20090923085336.679:AnonymousBlock: line 11, column 1: schemasMicrosoftComSharepointSoapDw.DwsSoap dwssoap.outputHttpHeaders_x <= NewMap20090923085336.679:AnonymousBlock: line 14, column 1: DeclareVar: String authorizationHeader20090923085336.679:AnonymousBlock: line 14, column 1: initial value: Basic dXNlcm5hbWU6cGFzc3dk20090923085336.679:AnonymousBlock: line 15, column 1: MAP:String,String.put(String, String)20090923085336.679:AnonymousBlock: line 18, column 1: DeclareVar: String Result20090923085336.679:AnonymousBlock: line 18, column 1: Entering user sharing mode20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw.DwsSoap.CreateFolder: line 237, column 13: DeclareVar: schemasMicrosoftComSharepointSoapDw.CreateFolder_element request_x20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 42, column 18: Instance initialization: CreateFolder_element20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 43, column 16: DeclareVar: public String url20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 44, column 17: DeclareVar: private LIST:String url_type_info20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 44, column 17: initial value: (url, http://www.w3.org/2001/XMLSchema, string, 0, 1, false)20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 45, column 17: DeclareVar: private LIST:String apex_schema_type_info20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 45, column 17: initial value: (http://schemas.microsoft.com/sharepoint/soap/dws/, true, false)20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 46, column 17: DeclareVar: private LIST:String field_order_type_info20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw: line 46, column 17: initial value: (url)20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw.DwsSoap.CreateFolder: line 237, column 13: initial value: schemasMicrosoftComSharepointSoapDw.CreateFolder_element:[apex_schema_type_info=(http://schemas.microsoft.com/sharepoint/soap/dws/, true, false), field_order_type_info=(url), url=null, url_type_info=(url, http://www.w3.org/2001/XMLSchema, string, 0, 1, false)]20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw.DwsSoap.CreateFolder: line 238, column 13: DeclareVar: schemasMicrosoftComSharepointSoapDw.CreateFolderResponse_element response_x20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw.DwsSoap.CreateFolder: line 239, column 13: schemasMicrosoftComSharepointSoapDw.CreateFolder_element request_x.url <= String url20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw.DwsSoap.CreateFolder: line 240, column 13: DeclareVar: MAP:String,schemasMicrosoftComSharepointSoapDw.CreateFolderResponse_element response_map_x20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw.DwsSoap.CreateFolder: line 240, column 13: initial value: {}20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw.DwsSoap.CreateFolder: line 241, column 13: MAP:String,schemasMicrosoftComSharepointSoapDw.CreateFolderResponse_element.put(String, schemasMicrosoftComSharepointSoapDw.CreateFolderResponse_element)20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw.DwsSoap.CreateFolder: line 242, column 13: WebServiceCallout.invoke(schemasMicrosoftComSharepointSoapDw.DwsSoap, schemasMicrosoftComSharepointSoapDw.CreateFolder_element, MAP:String,schemasMicrosoftComSharepointSoapDw.CreateFolderResponse_element, LIST:String)20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw.DwsSoap.CreateFolder: line 242, column 13: Created Web Service callout to endpoint: http://i.mm1-consulting.de/_vti_bin/DWS.asmx20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw.DwsSoap.CreateFolder: line 242, column 13: Sending callout request20090923085336.679:Class.schemasMicrosoftComSharepointSoapDw.DwsSoap.CreateFolder: line 242, column 13: Reading callout response20090923085336.679:AnonymousBlock: line 18, column 1: Exiting user sharing mode20090923085336.679:AnonymousBlock: line 22, column 2: System.debug(System.CalloutException)20090923085336.679:AnonymousBlock: line 22, column 2: System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'20090923085336.679:AnonymousBlock: line 23, column 2: System.debug(String)20090923085336.679:AnonymousBlock: line 23, column 2: End of Exception handler.Cumulative resource usage:Resource usage for namespace: (default)Number of SOQL queries: 0 out of 100Number of query rows: 0 out of 10000Number of SOSL queries: 0 out of 20Number of DML statements: 0 out of 100Number of DML rows: 0 out of 10000Number of script statements: 29 out of 200000Maximum heap size: 0 out of 2000000Number of callouts: 1 out of 10Number of Email Invocations: 0 out of 10Number of fields describes: 0 out of 10Number of record type describes: 0 out of 10Number of child relationships describes: 0 out of 10Number of picklist describes: 0 out of 10Number of future calls: 0 out of 10Number of find similar calls: 0 out of 10Number of System.runAs() invocations: 0 out of 0Total email recipients queued to be sent : 0Static variables and sizes:DwsService:4dwssoap:211Cumulative profiling information:No profiling information for SOQL operations.No profiling information for SOSL operations.No profiling information for DML operations.1 most expensive method invocations:Class.schemasMicrosoftComSharepointSoapDw: line 236, column 23: public String CreateFolder(String): executed 1 time in 355 ms
My code is:
schemasMicrosoftComSharepointSoapDw DwsService = new schemasMicrosoftComSharepointSoapDw();schemasMicrosoftComSharepointSoapDw.DwsSoap dwssoap = new schemasMicrosoftComSharepointSoapDw.DwsSoap( );try {String username = 'username';String password = 'passwd';Blob headerValue = Blob.valueOf(username+':'+password);dwssoap.inputHttpHeaders_x = new Map<String, String>();dwssoap.outputHttpHeaders_x = new Map<String, String>();//Setting a basic authentication header String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);dwssoap.inputHttpHeaders_x.put('Authorization', authorizationHeader); // creates the folderstring Result = DwsSoap.CreateFolder('Test');}catch ( calloutexception e ) { System.debug( e); System.debug( 'End of Exception handler.');}
Is there a switch to turn on in order the see the callout response?
Hello Eric/All,
I am getting the same issue.
Please share the resolution if anybody is able to do it.
Thanks,
Hi, I also have this issue.
Does anybody have an answer to this case?
I consume the external webservice from everywhere and it works, but from Salesforce.
Thanks,
Wilmer
Hi, I'm having the same issue with an external webservice.
Do you have any sample of how could I build the test class specifically to Test a webservice and SEE the Sent and Received XML message?
I tried to do it from the Execute Anonymous in Salesforce and in Eclipse like this:
This is the class I use to process data, create objects and send the message.
What should I do?
Call only the method that executes the "invocation" to the webservice?
Regards,
Wilmer
Hi ,
I can consume an external web service from everywhere but salesforce... i tried to debug with Execute Anonymous and this is the result:
......
14:31:14.950 (125063000)|CALLOUT_REQUEST|[308,13]|<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header /><env:Body><SwitchNL xmlns="urn:TVolutionX"><p1>1</p1></SwitchNL></env:Body></env:Envelope>
14:31:14.950 (125114000)|CALLOUT_REQUEST|[308,13]|tvolutionx.SwitchNL_element request_x::SFDC_STACK_DEPTH=1 SOAPAction="" User-Agent=SFDC-Callout/19.0 Accept=text/xml Content-Type=text/xml; charset=UTF-8
14:31:15.487 (662338000)|CALLOUT_RESPONSE|[308,13]|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to retrieve the URL:
<A HREF="http://My URL">http:/My URL</A>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Zero Sized Reply
</STRONG>
</UL>
<P>
Squid did not receive any data for this request.
<P>Your cache administrator is <A HREF="mailto:support@salesforce.com">support@salesforce.com</A>.
I added my URL in the Remote Sites but still not working....
Any Idea??
Thank you so much!!
have you white listed SF IP's in your internal system?
Hi Maxa,
No i don´t have it . And according to the firewall logs, the access from the Salesforce server is successful
Thank you so much
Regarding not being able to see the XML for the SOAP request/response: I had the same issue & tried the same code in another org and was able to see the actual XML. I have no idea why it would differ from org to org. As far as I can tell everything is the same, except one org is a dev org and the one that wasnt showing the full callout was a sandbox.
I was not able to see detailed SOAP request/response in Sandbox, but migrated the code to Dev org and could see what the others have posted.
My issue was with respect to the DNS resolution.
"The requested URL could not be retrieved". I used the ip instead of site name and it worked.
But ended up with read time out issue even after setting the max timeout of 60 secs.
Working on it.
Thanks
Please suggest, how could you get the HTML output in debug mode by using execute Anonymous.
where exactly we have to hook debug message.
I have also facing same problem. Please help me out
Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'
Thank in advance.
Please make sure the webservice endpoint URL is added to the Remote Site Settings in Salesforce and Salesforce IP range is white listed in internal systems
It seems that at this moment (June/2012), the only way to see in debugger the exchanged XML message in a SOAP operation (Callout) is by making that callout from a Developer Edition Org.
Sad but True (as the song says...).
Hi,
I was facing same issue I have solved this problem. You have authentication error . You should pass username and password or proxy in header to call a web service.
Thanks
Hi Varun,
I am facing the same problem, can you please explain how you solved or copy your sample code for setting proxy, username and password
Thanks in adavance for your help
-Babu
Hi Babu,
You have to pass your credential in header. This is code for passing credential:
Thanks,
Varun
I have debugged in DEV instance. And i am able to see the complete HTML output error.
I got 401 Unauthorized error.
Below is the code. I have used WSDL2Apex and generated SalesforceCom class. In the below class, I am using that class and methods, sending Account_Code__c as the input parameter.
How do I send username and password to this ? I need to set that for the stub. (Not thru Http Request and Response)
Please help. Thanks.
Hi Mansih,
You are getting Unauthorized error because you are not passing username and password.
Hi Friends,
Any solution for this problem ??
I'm also facing same issue while making callout..Please reply as soon as possible.
Thanks,
Hi Bharat,
Make sure that you are passing client_id and client_secrete correctly.
Can you give me some more Idea about Client_Id and client_secrete as I'm not passing such information.
Varun,
I'm not getting Unauthorised access response but instead I got below mention exception.
ystem.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'
Hi Bharat,
In my case I was getting this error because I was not ablt to login in the system. My authentication was failed.
When authentication was successfull it returned xml. If it was failed it was going to error page which was html page. So it gives the error It was expecting XML but found HTML.
Thanks,
I have resolved this issue -"System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'" -- By Correcting my end point URL in the WSDL File at SOAP address location. See below example:
For e.g -<service name="WebServiceMathService">
<documentation></documentation>
<port binding="tns:WebServiceMathBinding" name="WebServiceMath">
<soap:address location="http://techysunil-developer-edition.ap1.force.com/services/Soap/class/WebServiceMath"/>
</port>
</service>
My WSDL URL is https://ap1.salesforce.com/services/wsdl/class/WebServiceMath and i have associated my Class-WebServiceMath (enabled apex class access in Public Access Settings for Site), that contain the web service method with my site url, as mentioned in the SOAP address location.
Through this generated WSDL, i have generate the apex class [Generate from WSDL] and use that class in my Controller Class. Means, I have successfully create the apex class with web service method in one salesforce instance, and cosnume this web service method in another salesforce intsance through SOAP.
Thanks
Sunil Sharma
i completely agree to what you are saying.
But can you please tell me as to how do i provide credentials for invoking my WSDLToApex class?
Below is my post
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AsHIIA0