5
  <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

3

2 Answers 2

5

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

6
  • excellent!Thanks for the reply!Awesome and thanks again! Jan 24, 2013 at 5:47
  • SoapUI is an excellent tool for generating the XML you need to send.
    – Matt Lacey
    Jan 24, 2013 at 5:50
  • Do you know if there exists any wrapper or other workaround instead generating the XML to send and analysing the response parsing the result? Nov 29, 2013 at 11:33
  • @MartinBorthiry, I have documented my approach here: blog.dacology.com/…
    – dacology
    Jan 20, 2015 at 12:04
  • 1
    @dacology The link is not working. Can you please check and reshare? Thanks Dec 26, 2023 at 15:45
3

As an alternative you can also modify the generated APEX class, adding a security header. That way you won't have to generate the entire xml string from scratch.

This is described in detail here: http://blog.dacology.com/callouts-from-salesforce-adding-soap-headers-for-wsse-security/ and here: https://stackoverflow.com/questions/5018961/soap-security-in-salesforce

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .