I am getting the below error for a callout with the external system soon after the after the expiry of self signed certificate in salesforce and it has been replaced with new one with the same name. Prior to the certificate expiry the callout was working fine. The error received is as follows: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found 'http://www.w3.org/1999/xhtml:html'

Could you please help on how this issue can be debugged?

  • 2
    Can you edit your post to include your code?
    – Adrian Larson
    Commented Sep 16, 2016 at 17:46
  • May also help if you share a response sample, seeing the returned response may not be what your code is expecting. Do you understand the error message ? Commented Sep 17, 2016 at 10:06
  • Hi all, we are consuming a WSDL and then initiating the callout in the normal way as we do for SOAP API. This callout was working perfectly fine until the expiry of CSR Refund Request certificate (type=self signed) and its subsequent replacement with new one with the same name. No code changes or configuration changes have been done on both the sides. Commented Sep 19, 2016 at 6:20

1 Answer 1


This error means that your code was expecting a SOAP response, but got back an HTML response instead. Most likely a 4XX or 5XX error (e.g. not authorized, bad request, etc). Check your debug logs for errors. Consider changing the callouts debug level to "finest" (Developer Console > Debug > Change Log Levels...) so that you can see the request and response data directly in the log file. You may also need to contact your service provider/server admin to figure out what's going on.

You must log in to answer this question.

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