0

I have a WSDL from a vendor which includes a method that expects one of the params ('Xmldoc') to be embedded XML. The WSDL for the method:

<s:element name="ImportGuest">
  <s:complexType>
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="DbUserName" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="DbPassword" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="DbName" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Server" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Platform" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Xmldoc">
        <s:complexType mixed="true">
          <s:sequence>
            <s:any />
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:sequence>
  </s:complexType>
</s:element>

And the documentation of ImportGuests is:

The ImportGuest message request requires the following six parameters:
DbUserName - User Name - String
DbPassword - Password - String
DbName - Database Name - String
Server - Server Name - String
Platform - SQL Server - String
XmlDoc - XML document containing prospect information. See “XML Document Specification” on page 3.

The XML Doc specification is basically an object with a couple dozen fields, serialized as an XML element with each field as a child element.

So it is expecting the soap request body to include an element called Xmldoc which includes basically more XML. Sample from the docs:

<soap:Body>
  <ImportGuest xmlns="Vendor.Portal.Product.WebServices">
    <DbUserName>example</DbUserName>
    <DbPassword>example</DbPassword> 
    <DbName>example</DbName> 
    <Server>example</Server> 
    <Platform>SQL Server</Platform> 
    <Xmldoc>
      <Leads>
        <Lead>
          <SourceName>Community Website</SourceName>
          <ExtReference>1-1</ExtReference> 
          <PropertyCode>a10</PropertyCode> 
          <FirstName>LeadTest1</FirstName> 
          <!-- snip -->
        </Lead> 
      </Leads> 
    </Xmldoc>
  </ImportGuest> 
</soap:Body>  

I can generate the XML doc content directly, but how can I insert that into the body? The method generated by WSDL2APEX looks like:

public SoapWrapper.ImportGuestResult_element ImportGuest(
  String DbUserName,
  String DbPassword,
  String DbName,
  String Server,String Platform,
  SoapWrapper.Xmldoc_element Xmldoc
)

And 'Xmldoc_element' has no public members:

public class Xmldoc_element {
    private String[] apex_schema_type_info = new String[]{'Vendor.Portal.Product.WebServices','true','false'};
    private String[] field_order_type_info = new String[]{};
}

So how do I specify Xmldoc as the embedded content? Is my only choice to modify the WSDL to model the entire Xmldoc as an object? If I do that, will blank fields be passed, and can I suppress? It isn't clear from the spec if blank fields (as opposed to missing fields) are allowed, although I plan to check with the vendor.

  • Are you able to share the WSDL? Feel free to change the endpoint and find/replace any sensitive namespaces etc... – Daniel Ballinger Aug 8 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.