3

We have to consume a WSDL in salesforce where we need to send a soap header element which is of simple data type to an external webservice. The problem is that wsdl2apex parser rejects the simple data type and when i convert this to a complex type, it ends up as duplicate on the soap request`

  <xsd:element name="Service">
    <xsd:simpleType>
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="loan.CreateLead" />
      </xsd:restriction>
    </xsd:simpleType>
  </xsd:element>

  <xsd:element name="MajorVersion">
    <xsd:simpleType>
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="1" />
      </xsd:restriction>
    </xsd:simpleType>
  </xsd:element>
  <xsd:element name="MinorVersion">
    <xsd:simpleType>
      <xsd:restriction base="xsd:string" />
    </xsd:simpleType>
  </xsd:element>

soap:body use="literal" />

You would notice the header message has 3 elements of simple type Service, MajorVersion and MinorVersion and the wsdl binding sends these elements as soap header. I know enumeration and restrictions tags are not allowed on call outs. So the question, what is the simple xsd tag for Service, MajorVersion and MinorVersion i can use which should be simple type format which would allow me to get through the apex2wsdl parser and get the expected results?

  • I am uploading the actual wsdl for your reference here. drive.google.com/file/d/0B3g0ogHiFUVNS0ZMRWVIS2FnVUU/… – buyan kumar Oct 24 '13 at 16:35
  • If you upload this wsdl to your org, it would fail on the gwheader element. I want the equivalent simple type for the 3 elements service, majorversion and minor version on document type literal format please? any help would be appreciated.. – buyan kumar Oct 24 '13 at 16:37
3

I haven't tried it, but essentially they are all just strings. So you could just drop the restrictions and make them strings. Something like:

<xsd:element name="Service" type="xsd:string"/>
<xsd:element name="MajorVersion" type="xsd:string"/>
<xsd:element name="MinorVersion" type="xsd:string"/>

Just make sure you follow the restrictions when setting the actual values that get passed to the web service.

| improve this answer | |
0

Thanks Daniel for your answer. The bottom line is that if there is header information to be passed from saleforce to any external WSDL, you need to pass it as a complex data type. Simple data types will not be accepted as they dont follow the document literal type standard.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.