+ Start a Discussion

Web service callout failed

Hi I am trying to integrate salesforce.com with Oracle Apps using BPEL. I have published my BPEL as a webservice in our test server and had created an apex class which calls this webservice. Later I am invoking this using an S-control button in Accounts tab.

But I am getting the following error when I invoke the button.

{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’

Class.wwwTrianzCom.Create_AccountPort.process: line 15, column 13
Class.AccountWrapper.CreateFunction: line 5, column 10

Please help me to figure out the problem.

Thank you, Aneesh
If you are executing the webservice from an scontrol, you can try using Firefox plugins like Firebug and LiveHTTPHeaders to see the web service request and response. With that, you can verify if the message looks appropriate.

If you are executing the webservice from within an apex class, I have used the Execute Anonymous View within the Force.com IDE to output the apex generated web service request and response.

It sounds like your response message is not being properly parsed and handled.
Your endpoint returned an HTML page, instead of the expected SOAP document. You'll have to trace things on your side.

Hi, I'm getting the same issue, how did see the request XML message? I also used the Execute Anonymous from Force.com IDE on Eclipse but I can´t see those details? Is there any special instructions to be able to see that?


I get the "System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'" error message, do you know what could be wrong?







Can you please post the solution if you figured out whats the issue is with.. thank you


Hi Aneesh,


Well, in fact, there should be a communication error between servers and that message doesn't help so much.


What to do? (only to see better what's going on)

1. Load the apex class that invokes the external webservice (from SFDC) in a trusted Developer Edition org, (if you want to, use the Generate from WSDL button at the apex classes list by parsing the given WSDL or just copy and paste the one you've developed in your original org).


2. Develope another apex class (NOT a Test class) that calls the class of point 1. You don't need to replicate the data model from your original org, only build the Apex objects and their attribute values the first class requires to make the callout work.


3. Run the second class using "Execute Anonymous" in your Eclipse project. Now, you should be able to see the exchanged XML message (request and response), and in this case, you'll see the HTML detail you're  getting in your response.


NOTE: Don't forget to set the Remote Site location in SFDC, and try to set (if possible) the testing environment of the external webservice as your webservice endpoint.


I hope this information helps and I also would like Salesforce to activate the callout detail (possibility to see the XML format of webservice messages) in production and Sandbox org - THIS IS ONLY POSSIBLE in Developer's orgs (At least until today).





.Net Api.Net Api


Can Any One resolve this issue


Iam calling one api (Webservice),it has returned this error

Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope



Thanks in Advance




 Kranthi Nagisetty





Why don't you check the webservice availability? Did you test it from a Salesforce Developer edition? Remenber, there you could see the XML of the message (request and response).








I see the request, but no response. Its just displaying that error message.


Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'


Any help would be appreciated.





Sunil SharmaSunil Sharma
Hello All,

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">
  <port binding="tns:WebServiceMathBinding" name="WebServiceMath">
   <soap:address location="http://techysunil-developer-edition.ap1.force.com/services/Soap/class/WebServiceMath"/>

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 instance through SOAP.

Sunil Sharma
Hi Sunil ,
I am doing the same SF - SF connection using SOAP/ WSDL .

I have done following things :
In my first SF org :
Created Global Class and Added method with keyword as webservice .
Created WSDL of this class

In my second SF org 
Generated Class from the above WSDL .
Added instance in the remote site setting

Now from developer console I am trying to execute the webservice method like 

soapSforceComSchemasClassAnkuliserv.AnkuliService consumer = new soapSforceComSchemasClassAnkuliserv.AnkuliService();
consumer.SessionHeader = new soapSforceComSchemasClassAnkuliserv.SessionHeader_element();
consumer.SessionHeader.sessionId = UserInfo.getSessionId();
String test = consumer.someMethod2('derp');

soapSforceComSchemasClassAnkuliserv = Class generated from WSDL
AnkuliService = Inner Class 

I am getting following error :

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: No service available for class 'AnkuliService' faultcode=soapenv:Client faultactor=: Class.soapSforceComSchemasClassAnkuliserv.AnkuliService.someMethod2: line 43, column 1 AnonymousBlock: line 6, column 1 AnonymousBlock: line 6, column 1

Any thoughts ?

Thanks ,

Sunil SharmaSunil Sharma
Hi Ajay,

Check for your apex class(that contains the web service method) access in Public Access Settings for Site, Enable its access.

Hi Sunil ,
Thanks for your reply .
But I am not using site for this . I have not created any site . So then how to progress ?

Thanks ,
Saranya MSaranya M
Hi Ajay,

I'm also facing the same issue. Did you get an answer for your question?


Hi Saranya ,

Actually I am trying to connect two salesforce org during my time.

The root cause of problem was at that time I am not adding the UserName or Password of the org where I am trying to connect.

After providing the combination I am not getting the error.


Saranya MSaranya M
Hi Ajay, Actually I have provided the username and password of the org where I am consuming the webservice. But still I'm getting the error. Thanks & Regards, Saranya