3

I have generated classes from WSDL file. I'm trying to execute a method from the generated class, there I'm getting the below error.

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

What can I change to avoid the error?

5
  • You can try to fix your class according to your endpoint specifications
    – kurunve
    Commented Jul 20, 2017 at 15:45
  • 2
    Your server is returning an error page, in HTML. You'll want to use something like SoapUI to diagnose the issue.
    – sfdcfox
    Commented Jul 20, 2017 at 15:52
  • @sfdcfox OK,I'll check
    – Rock SFDC
    Commented Jul 20, 2017 at 16:15
  • Another option would be to use Assertible (assertible.com) or Postman (getpostman.com) to debug the issues. Both are free to use and similar to SoapUI, but a little more modern (I am a founder at Assertible. Good luck!).
    – creichert
    Commented Jul 20, 2017 at 19:40
  • @RockSFDC If you are in a debug org, check for the CALLOUT_REQUEST and CALLOUT_RESPONSE pair in the debug log. You might be able to see the problem response there. Commented Jul 21, 2017 at 3:54

1 Answer 1

2

This occurs when the external service didn't return a SOAP response. In this case, rather than a SOAP envelope element there is an html element at the start of the response.

As @sfdcfox commented, this indicates the service is returning an HTML response. It's likely some sort of error page, security response, or a redirect.

In a Salesforce Debug org you can check the Apex debug log for the CALLOUT_REQUEST and CALLOUT_RESPONSE pair. The latter should show you exactly what is coming back.

2
  • Troubleshooting a similar error. For what it's worth, I have the Callout category on my debug level set to "FINEST", and I don't see any CALLOUT_RESPONSE in my logs. Commented Feb 11, 2022 at 18:46
  • 1
    @MatthewSouther The CALLOUT_RESPONSE won't appear in production orgs. Try making the callout from a developer edition org. Commented Feb 13, 2022 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .