[SalesForce] Forming SOAP header through apex class if the WSDL provided has no information regarding the header

  <soapenv:Header>
  <wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:SOAP-ENV="SOAP-ENV">
     <wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <wsse:Username>oneview</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">oneview123</wsse:Password>
     </wsse:UsernameToken>
  </wsse:Security>

Here is how my header is structured in request .By default when my stub is generated from WSDL no information regarding header in WSDL .So is there any code in apex i can start and include in my stub class and create this kind of header.

Update:

<wsp:Policy wsu:Id="UsernameToken" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
    <wsp:ExactlyOne>
        <wsp:All>
            <sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
                <wsp:Policy>
                    <sp:UsernameToken sp:IncludeToken=".../IncludeToken/AlwaysToRecipient"/>
                </wsp:Policy>
            </sp:SupportingTokens>
        </wsp:All>
    </wsp:ExactlyOne>
</wsp:Policy>

The WSDL has wsp and policy .Do WSDL to apex support this.Any help appreciated

Best Answer

The standard WSDL-->Apex feature does not support including any WSS or WSP headers in the outgoing SOAP request. You will need to forgo the WSDL-->Apex generated classes and instead manually construct the request SOAP message and then invoke the web service using the Apex HTTP callout classes. This thread should be helpful in showing you how to do this - http://boards.developerforce.com/t5/Apex-Code-Development/SOAP-Webservice-Callout-Issue-Generating-Output-Headers-Response/m-p/171411/highlight/true#M26424. Hope this helps.

Sandeep

Related Topic