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
baseball123baseball123 

Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'

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

 

Can anyone tell me how I can generate some test code in Execute Anonymous to troubleshoot the following Callout SOAP request and response. The callout logic is very simple and it's about celsius to farenheit conversion. 

 

//Generated by wsdl2apex

public class ConverterWS {
    public class ConverterHttpSoap11Endpoint {
        public String endpoint_x = 'http://localhost:8080/Axis2WSTest/services/Converter.ConverterHttpSoap11Endpoint/';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://wtp', 'ConverterWS'};
        public Double celsiusToFarenheit(Double celsius) {
            ConverterWS.celsiusToFarenheit_element request_x = new ConverterWS.celsiusToFarenheit_element();
            ConverterWS.celsiusToFarenheitResponse_element response_x;
            request_x.celsius = celsius;
            Map<String, ConverterWS.celsiusToFarenheitResponse_element> response_map_x = new Map<String, ConverterWS.celsiusToFarenheitResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'urn:celsiusToFarenheit',
              'http://wtp',
              'celsiusToFarenheit',
              'http://wtp',
              'celsiusToFarenheitResponse',
              'ConverterWS.celsiusToFarenheitResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.return_x;
        }
        public Double farenheitToCelsius(Double farenheit) {
            ConverterWS.farenheitToCelsius_element request_x = new ConverterWS.farenheitToCelsius_element();
            ConverterWS.farenheitToCelsiusResponse_element response_x;
            request_x.farenheit = farenheit;
            Map<String, ConverterWS.farenheitToCelsiusResponse_element> response_map_x = new Map<String, ConverterWS.farenheitToCelsiusResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'urn:farenheitToCelsius',
              'http://wtp',
              'farenheitToCelsius',
              'http://wtp',
              'farenheitToCelsiusResponse',
              'ConverterWS.farenheitToCelsiusResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.return_x;
        }
    }
    public class celsiusToFarenheit_element {
        public Double celsius;
        private String[] celsius_type_info = new String[]{'celsius','http://www.w3.org/2001/XMLSchema','float','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://wtp','true','true'};
        private String[] field_order_type_info = new String[]{'celsius'};
    }
    public class celsiusToFarenheitResponse_element {
        public Double return_x;
        private String[] return_x_type_info = new String[]{'return','http://www.w3.org/2001/XMLSchema','float','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://wtp','true','true'};
        private String[] field_order_type_info = new String[]{'return_x'};
    }
    public class farenheitToCelsiusResponse_element {
        public Double return_x;
        private String[] return_x_type_info = new String[]{'return','http://www.w3.org/2001/XMLSchema','float','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://wtp','true','true'};
        private String[] field_order_type_info = new String[]{'return_x'};
    }
    public class farenheitToCelsius_element {
        public Double farenheit;
        private String[] farenheit_type_info = new String[]{'farenheit','http://www.w3.org/2001/XMLSchema','float','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://wtp','true','true'};
        private String[] field_order_type_info = new String[]{'farenheit'};
    }
}

sham_1sham_1

Hi,

I have seen this error, couple of times during my development cycle.

The most likely cause of the error , is the webservice that you are trying to call is throwing an exception.

Its most likely a webservice built using .NET framework.

 

Also the end point url, seems to be incorrect, its pointing to localhost, it should have the server IP or name.

http://localhost:8080/Axis2WSTest/services/Conver

ter.ConverterHttpSoap11Endpoint

 

baseball123baseball123

I have changed the localhost to actual IP but still the same error message.

 

I published this web service from one of my Java Dynamic Web Projects.

 

If I want to monitor the SOAP request and response by using Eclipse's Execute Anonymous, can you give me some sample code of writing the test program by using the code I have posted?

 

Thanks,

sham_1sham_1

Hi,

Can you invoke the webservice externally, using SOAP UI tool.

 

I believe the problem is not with the SFDC code, but with the webservice configuration,Its either not being fully exposed to the  or  its always returning an exception.

 

IF the webservice is being called, externally it should be callable with Apex code.

riffindusriffindus

Hi Baseball,

 

Did you get any solution for your issue. Even i am gettting same error. But when i request using SOAP UI. it is giving response properly.

 

 

Gabriel Ejezie 4Gabriel Ejezie 4
Was anyone able to resolve this issue? I'm currently facing the same issue and not sure what to do to resolve it.
 
Eugene Mutya 13Eugene Mutya 13
was this solve? I am getting the same issue right now. it says: 

Line: 67, Column: 1
System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found 'http://schemas.xmlsoap.org/wsdl/:definitions'