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
chirayu.bansal1.3892593529263923E12chirayu.bansal1.3892593529263923E12 

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

Hi,
while make a webservice call out I am getting below error: 

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

Can someone help on this. How rto resolve it?
Thanks,

Vinita_SFDCVinita_SFDC
Hello,

Please share code, how are you making web service callout. Error is telling that web service is returning HTML insead of SAOP document.
chirayu.bansal1.3892593529263923E12chirayu.bansal1.3892593529263923E12

Please see below code which I am trying for this:

public class TestUtility_Cls{
   
    public list<Test_webService.KeyValuePair> IOG_pair = new list<Test_webService.KeyValuePair>();
    public pageReference calltestServices(){

        I_pair = new list<Test_webService.KeyValuePair>();
        Test_webService.webPort bindobj = new Test_Iwebervice.RtPort();
            bindobj.clientCertName_x = 'xxxxxxxxxxxxxx';
            bindobj.timeout_x = 120000;
            bindobj.inputHttpHeaders_x = new Map<String, String>();
            bindobj.inputHttpHeaders_x.put('Authorization', 'xxxxxxxxx');        
           
        Test_webService.KeyValuePair I_KeyValue = new Test_webService.KeyValuePair();
            I_KeyValue.key = 'SessionId';
            I_KeyValue.value = 'Carrie09';
            I_pair.add(I_KeyValue);
           
            I_KeyValue = new Test_webService.KeyValuePair();
            I_KeyValue.key = 'CR';
            I_KeyValue.value = 'ExOffer';
            I_pair.add(I_KeyValue);
           
            Test_webService.ArrayOfKeyValuePair kevapair = new Test_webService.ArrayOfKeyValuePair();
            kevapair.attribute = I_pair;
           
            Test_webService.ProcessEventResponse_element IResp = new Test_webService.ProcessEventResponse_element();
            IResp = bindingobj.ProcessEvent('QA', 'GetOffers', kevapair);
           
        return null;    
    }
   
   
}


Here I am using WSDL generated class's method.

Vinita_SFDCVinita_SFDC
Hello,

Please check following things:

1) Webservice  endpoint URL is added to the Remote Site Settings in Salesforce

2) Salesforce IP range are white listed.

3) What are you getting in Debug logs?
chirayu.bansal1.3892593529263923E12chirayu.bansal1.3892593529263923E12

1.) Remote site setting is already set.
3.) In debug logs and in response I am getting below error:

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

gautam_singhgautam_singh
Hi Chirayu

This error comes when you are invoking external web service and there is any exception which is returning an HTML Page like 404 not found, or any other. If you have not received the answer to this question.Please confirm the following points within your organization. 
 
    1. Ensure that the web-service is hosted in internet. Salesforce cannot access a webservice that is in intranet.
    2. Since webservice is returning a HTML it can be page like 404 or authentication page. Make sure you are pointing to correct endpoint and using proper authentication.
    3. Also if there is firewall make sure you have white-listed the sales-force IP. You can get the IP here (http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_om_outboundmessaging_security.htm" target="_blank).
   
 Hope this helps.



Important :

If you have received the answer which you are looking for, Please mark it as a Solution, this will help others to find the resolution of problem with ease. More, you can make the Developers of the Community smile by appreciating the answer with the "Like" Button. We would love to help you again. 

Thank You
Gautam
Blog - http://singhgautam02.blogspot.in/
Me   - about.me/singhgautam