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
anurag singh 22anurag singh 22 

Web service callout failed: Unexpected element. Parser was expecting element '' but found ':html'

Hi guys I am trying to inovke a webservice call using the classes generated from the wsdl2apex and I get the following error and I am not sure what exactly the issue is when I use soapui I get a response any help here would be appreciated
Silje OlsenSilje Olsen
it could be several things causing it. I find debugging webservices in Salesforce hard, since there are never much information provided in the error messages. Below are some methods that I find usefull when debugging:

1) There is a website that collects and displays requests that you send to it:
You can compare the two requests from Salesforce and SoapUI and verify that the request from salesforce is correct.

2) You could also try checking if the endpoint is available from Salesforce with a regular GET call. I usually use something like this to filter out connectivity issues:
HttpRequest req = new HttpRequest();
     req.setEndpoint('your endpoint');
     Http http = new Http();
     HTTPResponse res = http.send(req);

3) If the request is not too complex you can also try to send it with the HttpRequest class instead of the WebServiceCallout.invoke() that are generated by wsdl2apex. You can use the request in SoapUI to compose the body for the request. See the SF doc here:
Combine this with number 1) to check that the requests are equal.

Hope this is helpful :)
Kiran Kumar GottulaKiran Kumar Gottula