Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  <wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:SOAP-ENV="SOAP-ENV">
     <wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="">
        <wsse:Password Type="">oneview123</wsse:Password>

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.


<wsp:Policy wsu:Id="UsernameToken" xmlns:wsu="" xmlns:wsp="">
            <sp:SupportingTokens xmlns:sp="">
                    <sp:UsernameToken sp:IncludeToken=".../IncludeToken/AlwaysToRecipient"/>

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

share|improve this question
Do you have the WSDL your trying to use? In some cases you can modify the generated code afterwards to add the missing bits the WSDL to Apex tool did not output. – Andrew Fawcett Jan 24 '13 at 14:01
@AndrewFawcett The above link is my wsdl.I could not modify anyting and get this working :( – Mohith Shrivastava Jan 24 '13 at 16:07
up vote 3 down vote accepted

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 - Hope this helps.


share|improve this answer
excellent!Thanks for the reply!Awesome and thanks again! – Mohith Shrivastava Jan 24 '13 at 5:47
SoapUI is an excellent tool for generating the XML you need to send. – LaceySnr Jan 24 '13 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? – Martin Borthiry Nov 29 '13 at 11:33
@MartinBorthiry, I have documented my approach here:… – dacology Jan 20 '15 at 12:04
@dacology , thanks for the solution, It works perfect! – apn May 17 '15 at 0:09

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: and here:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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