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
Srinivasaragavan JayakumarSrinivasaragavan Jayakumar 

'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'

I generated the class with the wsdl provided by my JAVA team. When i use the API i get the following error.

'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'

When i analysed the resquest i understood the the SOAP tags miss the name space. 

The SOAP request that is expected is 

<m:uploadDoc xmlns:m="http://docuploadws.esb.pra.com/">
        <m:DocMessage>
            <m:ClinicalProtocolSite>
                <SponserName>001i000001e0vJMAAY</SponserName>
                <ArtifactRefName>Protocol Documents</ArtifactRefName>
                <ProtocolNumber>Recurrent Abdominal Pain in Children</ProtocolNumber>
                <PRAUserId>005i00000015wLDAAY</PRAUserId>
            </m:ClinicalProtocolSite>

But what i receive is like 

<m:uploadDoc xmlns:m="http://docuploadws.esb.pra.com/">
        <DocMessage>
            <ClinicalProtocolSite>
                <SponserName>001i000001e0vJMAAY</SponserName>
                <ArtifactRefName>Protocol Documents</ArtifactRefName>
                <ProtocolNumber>Recurrent Abdominal Pain in Children</ProtocolNumber>
                <PRAUserId>005i00000015wLDAAY</PRAUserId>
            </ClinicalProtocolSite>

How can i get the namespace along with the tag name. Can someone help me on this issue. 
Daniel BallingerDaniel Ballinger

So, you have Apex code code calling an external web service.

The most probably cause from that error message is that the callout isn't reaching the web service and something is sending back an HTML response rather than a SOAP response.

Can you get the complete Apex Debug log from when the problem occured? It will have the CALLOUT_RESPONSE which will probably show the underlying problem.

See also: 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html' (https://developer.salesforce.com/forums/?id=906F00000008wHDIAY)
 

Srinivasaragavan JayakumarSrinivasaragavan Jayakumar
But as i said earlier, when i just add namespace for the tags it started to work.
Daniel BallingerDaniel Ballinger
OK. The most probable cause would be a problem with the Wsdl2Apex generated Apex classes. When WebServiceCallout.invoke() is called it picks up the namespace details from the _type_info members on the classes. The namespaces is often the first or second parameter in the array.

Are you able to share the path to the WSDL?
Srinivasaragavan JayakumarSrinivasaragavan Jayakumar
Hi Daniel


Logs are

05:19:54.272 (272788592)|ENTERING_MANAGED_PKG|
05:19:54.272 (272808442)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:-4
05:19:54.272 (272825135)|STATEMENT_EXECUTE|[91]
05:19:54.272 (272832940)|HEAP_ALLOCATE|[95]|Bytes:4
05:19:54.272 (272844108)|ENTERING_MANAGED_PKG|
05:19:54.272 (272870097)|HEAP_ALLOCATE|[98]|Bytes:9
05:19:54.272 (272877140)|HEAP_ALLOCATE|[100]|Bytes:17
05:19:54.272 (272882682)|HEAP_ALLOCATE|[101]|Bytes:30
05:19:54.272 (272905018)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:32
05:19:54.272 (272928047)|ENTERING_MANAGED_PKG|
05:19:54.477 (477652189)|CALLOUT_REQUEST|[91]|<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header /><env:Body><m:uploadDoc xmlns:m="http://docuploadws.yyy.xxx.com/"><DocMessage><ClinicalProtocolSite><SponserName /><ArtifactRefName>Protocol Documents</ArtifactRefName><ProtocolNumber>Study on disorder</ProtocolNumber><PRAUserId>005i00000015wLDAAY</PRAUserId></ClinicalProtocolSite><ActionAttachment><ExternalDocumentId>a0Yi0000009haoFEAQ</ExternalDocumentId><DocumentDate>2015-10-21</DocumentDate><ActivityFileExt>docx</ActivityFileExt><ActivityFileName>Click on submit for approvel.docx</ActivityFileName><FileType>docx</FileType><FileSystem /></ActionAttachment><DocMetadata><Dummy xsi:nil="true" /><Metadata><Name>Domain Name</Name><Value>6.0 IP and Trial Supplies</Value></Metadata><Metadata><Name>Group Name</Name><Value>2.2 Subject Documents</Value></Metadata><Metadata><Name>Artifact Name</Name><Value>Protocol Documents</Value></Metadata><Metadata><Name>Protocol Number</Name><Value>Study on disorder</Value></Metadata><Metadata><Name>Document Date</Name><Value>2015-10-21</Value></Metadata><Metadata><Name>Sponsor</Name><Value /></Metadata><Metadata><Name>PRA Project ID</Name><Value /></Metadata></DocMetadata></DocMessage></m:uploadDoc></env:Body></env:Envelope>
05:19:54.478 (478012468)|CALLOUT_REQUEST|[91]|uploadDoc:[DocMessage=DocMessage_element:[ActionAttachment=ActionAttachment_element:[ActivityFileExt=docx, ActivityFileExt_type_info=(ActivityFileExt, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), ActivityFileName=Click on submit for approvel.docx, ActivityFileName_type_info=(ActivityFileName, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), Description=null, Description_type_info=(Description, http://docuploadws.yyy.xxx.com/, null, 0, 1, false), DocumentDate=2015-10-21, DocumentDate_type_info=(DocumentDate, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), ExternalDocumentId=a0Yi0000009haoFEAQ, ExternalDocumentId_type_info=(ExternalDocumentId, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), FileSystem=null, FileSystem_type_info=(FileSystem, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), FileType=docx, FileType_type_info=(FileType, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(ExternalDocumentId, DocumentDate, ActivityFileExt, ActivityFileName, Description, FileType, FileSystem)], ActionAttachment_type_info=(ActionAttachment, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), ClinicalProtocolSite=ClinicalProtocolSite_element:[ArtifactRefName=Protocol Documents, ArtifactRefName_type_info=(ArtifactRefName, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), PRAUserId=005i00000015wLDAAY, PRAUserId_type_info=(PRAUserId, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), ProjectId=null, ProjectId_type_info=(ProjectId, http://docuploadws.yyy.xxx.com/, null, 0, 1, false), ProtocolNumber=Study on disorder, ProtocolNumber_type_info=(ProtocolNumber, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), SiteName=null, SiteName_type_info=(SiteName, http://docuploadws.yyy.xxx.com/, null, 0, 1, false), SiteNumber=null, SiteNumber_type_info=(SiteNumber, http://docuploadws.yyy.xxx.com/, null, 0, 1, false), SponserName=null, SponserName_type_info=(SponserName, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(SiteName, SiteNumber, ProjectId, SponserName, ArtifactRefName, ProtocolNumber, PRAUserId)], ClinicalProtocolSite_type_info=(ClinicalProtocolSite, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), DocMetadata=DocMetadata_element:[Dummy=null, Dummy_type_info=(Dummy, http://docuploadws.yyy.xxx.com/, null, 1, 1, true), Metadata=(Metadata_element:[Name=Domain Name, Name_type_info=(Name, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), Value=6.0 IP and Trial Supplies, Value_type_info=(Value, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(Name, Value)], Metadata_element:[Name=Group Name, Name_type_info=(Name, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), Value=2.2 Subject Documents, Value_type_info=(Value, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(Name, Value)], Metadata_element:[Name=Artifact Name, Name_type_info=(Name, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), Value=Protocol Documents, Value_type_info=(Value, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(Name, Value)], Metadata_element:[Name=Protocol Number, Name_type_info=(Name, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), Value=Study on disorder, Value_type_info=(Value, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(Name, Value)], Metadata_element:[Name=Document Date, Name_type_info=(Name, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), Value=2015-10-21, Value_type_info=(Value, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(Name, Value)], Metadata_element:[Name=Sponsor, Name_type_info=(Name, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), Value=null, Value_type_info=(Value, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(Name, Value)], Metadata_element:[Name=PRA Project ID, Name_type_info=(Name, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), Value=null, Value_type_info=(Value, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(Name, Value)]), Metadata_type_info=(Metadata, http://docuploadws.yyy.xxx.com/, null, 1, -1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(Dummy, Metadata)], DocMetadata_type_info=(DocMetadata, http://docuploadws.yyy.xxx.com/, null, 1, 1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(ClinicalProtocolSite, ActionAttachment, DocMetadata)], DocMessage_type_info=(DocMessage, http://docuploadws.yyy.xxx.com/, null, 0, 1, false), apex_schema_type_info=(http://docuploadws.yyy.xxx.com/, false, false), field_order_type_info=(DocMessage)]::SOAPAction="" Accept=text/xml User-Agent=SFDC-Callout/35.0 SFDC_STACK_DEPTH=1 Content-Type=text/xml; charset=UTF-8 
05:19:54.531 (531353431)|CALLOUT_RESPONSE|[91]|<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unmarshalling Error: unexpected element (uri:"", local:"ClinicalProtocolSite"). Expected elements are &lt;{http://docuploadws.yyy.xxx.com/}ClinicalProtocolSite>,&lt;{http://docuploadws.yyy.xxx.com/}ActionAttachment>,&lt;{http://docuploadws.yyy.xxx.com/}DocMetadata> </faultstring></soap:Fault></soap:Body></soap:Envelope>
05:19:54.531 (531516650)|EXCEPTION_THROWN|[91]|System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Unmarshalling Error: unexpected element (uri:"", local:"ClinicalProtocolSite"). Expected elements are <{http://docuploadws.yyy.xxx.com/}ClinicalProtocolSite>,<{http://docuploadws.yyy.xxx.com/}ActionAttachment>,<{http://docuploadws.yyy.xxx.com/}DocMetadata>  faultcode=soap:Client faultactor=
05:19:54.531 (531643526)|HEAP_ALLOCATE|[91]|Bytes:357
05:19:54.531 (531682773)|METHOD_EXIT|[704]|01pi0000006bTjF|VHSSCDP.DocUploadyyy.DocUploadServicePort.uploadDoc(VHSSCDP.DocUploadyyy.DocMessage_element)
05:19:54.531 (531728891)|SYSTEM_MODE_EXIT|false
05:19:54.531 (531797472)|FATAL_ERROR|System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Unmarshalling Error: unexpected element (uri:"", local:"ClinicalProtocolSite"). Expected elements are <{http://docuploadws.yyy.xxx.com/}ClinicalProtocolSite>,<{http://docuploadws.yyy.xxx.com/}ActionAttachment>,<{http://docuploadws.yyy.xxx.com/}DocMetadata>  faultcode=soap:Client faultactor=

Class.VHSSCDP.DocUploadyyy.DocUploadServicePort.uploadDoc: line 91, column 1
Class.VHSSCDP.PRAUploadCSR.uploadSendetmfURL: line 704, column 1
05:19:54.531 (531813075)|FATAL_ERROR|System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Unmarshalling Error: unexpected element (uri:"", local:"ClinicalProtocolSite"). Expected elements are <{http://docuploadws.yyy.xxx.com/}ClinicalProtocolSite>,<{http://docuploadws.yyy.xxx.com/}ActionAttachment>,<{http://docuploadws.yyy.xxx.com/}DocMetadata>  faultcode=soap:Client faultactor=

Class.VHSSCDP.DocUploadyyy.DocUploadServicePort.uploadDoc: line 91, column 1
Class.VHSSCDP.PRAUploadCSR.uploadSendetmfURL: line 704, column 1
05:19:54.531 (531829589)|CUMULATIVE_LIMIT_USAGE
05:19:54.531 (531829589)|LIMIT_USAGE_FOR_NS|(default)|


The WSDL for the same is
<?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions name="DocUploadServiceService" targetNamespace="http://docuploadws.yyy.xxx.com/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://docuploadws.yyy.xxx.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> -<wsdl:types> -<xs:schema targetNamespace="http://docuploadws.yyy.xxx.com/" xmlns:tns="http://docuploadws.yyy.xxx.com/" elementFormDefault="unqualified" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> -<xs:element name="ActionAttachment"> -<xs:complexType> -<xs:sequence> <xs:element name="ExternalDocumentId" type="xs:string"/> <xs:element name="DocumentDate" type="xs:string"/> <xs:element name="ActivityFileExt" type="xs:string"/> <xs:element name="ActivityFileName" type="xs:string"/> <xs:element name="Description" type="xs:string" minOccurs="0"/> <xs:element name="FileType" type="xs:string"/> <xs:element name="FileSystem" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> -<xs:element name="ClinicalProtocolSite"> -<xs:complexType> -<xs:sequence> <xs:element name="SiteName" type="xs:string" minOccurs="0"/> <xs:element name="SiteNumber" type="xs:string" minOccurs="0"/> <xs:element name="ProjectId" type="xs:string" minOccurs="0"/> <xs:element name="SponserName" type="xs:string"/> <xs:element name="ArtifactRefName" type="xs:string"/> <xs:element name="ProtocolNumber" type="xs:string"/> <xs:element name="PRAUserId" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> -<xs:element name="DocMessage"> -<xs:complexType> -<xs:sequence> <xs:element ref="tns:ClinicalProtocolSite"/> <xs:element ref="tns:ActionAttachment"/> <xs:element ref="tns:DocMetadata"/> </xs:sequence> </xs:complexType> </xs:element> -<xs:element name="DocMetadata"> -<xs:complexType> -<xs:sequence> <xs:element name="Dummy" type="xs:string" nillable="true"/> <xs:element ref="tns:Metadata" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> -<xs:element name="Metadata"> -<xs:complexType> -<xs:sequence> <xs:element name="Name" type="xs:string"/> <xs:element name="Value" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="uploadDoc" type="tns:uploadDoc"/> <xs:element name="uploadDocResponse" type="tns:uploadDocResponse"/> -<xs:complexType name="uploadDoc"> -<xs:sequence> <xs:element minOccurs="0" ref="tns:DocMessage"/> </xs:sequence> </xs:complexType> -<xs:complexType name="uploadDocResponse"> <xs:sequence/> </xs:complexType> </xs:schema> </wsdl:types> -<wsdl:message name="uploadDoc"> <wsdl:part name="parameters" element="tns:uploadDoc"> </wsdl:part> </wsdl:message> -<wsdl:message name="uploadDocResponse"> <wsdl:part name="parameters" element="tns:uploadDocResponse"> </wsdl:part> </wsdl:message> -<wsdl:portType name="DocUploadService"> -<wsdl:operation name="uploadDoc"> <wsdl:input name="uploadDoc" message="tns:uploadDoc"> </wsdl:input> <wsdl:output name="uploadDocResponse" message="tns:uploadDocResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType> -<wsdl:binding name="DocUploadServiceServiceSoapBinding" type="tns:DocUploadService"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> -<wsdl:operation name="uploadDoc"> <soap:operation style="document" soapAction=""/> -<wsdl:input name="uploadDoc"> <soap:body use="literal"/> </wsdl:input> -<wsdl:output name="uploadDocResponse"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> -<wsdl:service name="DocUploadServiceService"> -<wsdl:port name="DocUploadServicePort" binding="tns:DocUploadServiceServiceSoapBinding"> <soap:address location="http://localhost:55597/services/xxxx"/> </wsdl:port> </wsdl:service> </wsdl:definitions>


Srinivasaragavan JayakumarSrinivasaragavan Jayakumar
I've added both debug logs and wsdl contents above
Srinivasaragavan JayakumarSrinivasaragavan Jayakumar
Any help, its going critical for me.
Daniel BallingerDaniel Ballinger
When I tried making a mock Apex request to the service WebServiceCallout.invoke created the following request:
 
<?xml version="1.0" encoding="utf-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Header />
  <env:Body>
    <uploadDoc xmlns="http://docuploadws.yyy.xxx.com/">
      <DocMessage>
        <ClinicalProtocolSite />
        <ActionAttachment />
        <DocMetadata />
      </DocMessage>
    </uploadDoc>
  </env:Body>
</env:Envelope>
Note how the uploadDoc element defines the default namespace using the xmlns attribute. This namespace will apply of all the clild elements that don't define their own explicit namespace.

I do note that this differs from what you are seeing in your log:
<?xml version="1.0" encoding="utf-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Header />
  <env:Body>
    <m:uploadDoc xmlns:m="http://docuploadws.yyy.xxx.com/">
      <DocMessage>
        <ClinicalProtocolSite>
          <SponserName />
          <ArtifactRefName>Protocol Documents</ArtifactRefName>
          <ProtocolNumber>Study on disorder</ProtocolNumber>
          <PRAUserId>005i00000015wLDAAY</PRAUserId>
        </ClinicalProtocolSite>
        <ActionAttachment>         
          <!-- snip -->
        </ActionAttachment>
        <DocMetadata>
          <!-- snip -->
        </DocMetadata>
      </DocMessage>
    </m:uploadDoc>
  </env:Body>
</env:Envelope>

In your case the uploadDoc element isn't defining a default namespace. Rather it is creating the m aliais, which is only applied to the current element.

I generated the Apex code using the FuseIT SFDC Explorer (http://www.fuseit.com/explorer) custom WSDL2Apex functionality.This is something my work produces to help with Apex processing. Note that you might need to manually change the uploadDoc DocMessage parameter to be of type DocMessage_element.

I'd suggest you give our free custom tooling a try. You might also like to use the option to generate the equavalient HttpRequest. This will give you full control over the request from Apex. You can see details of how to do this in my Dreamforce 14 presentation - Using the Tooling API to Generate Apex SOAP Web Service Clients (https://www.youtube.com/watch?v=s23U1cglPcI).