function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CaffeineCaffeine 

How to set a SOAP Header using WSDL2Java

I know there are some Java/Axis gurus in salesforce, so I'm hoping one might answer the following:  how does one add a SOAP Header when using code generated by WSDL2Java?

 

Here are the details:

I'm trying to consume an authentication web service.  The WSDL specifies that the username and password are passed in the SOAP header.  Here is the relevant section of the WSDL:

<operation name="Logon">
      <soap:operation soapAction="http://MerrillLynch.Framework.Security/Logon" style="document" />
      <input>
        <soap:body use="literal" />
        <soap:header d5p1:required="true" message="s0:LogonAuthHeader" part="AuthHeader" use="literal" xmlns:d5p1="http://schemas.xmlsoap.org/wsdl/" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>

 

But in the Java code generated by WSDL2Java, I'm not seeing how add this SOAP header using the methods provided.    I've done the usual Googling, but there is nothing that I can that tells how to do it in a straightforward manner.

 

Does anyone know the trick?

 

Thanks.

 

 

CaffeineCaffeine

Problem solved:

AuthHeader ah = new AuthHeader();
        ah.setUserID("111testuser0115");
        ah.setPassword("xxxxxxx");
...

        WsSecLogonSoapStub w = (WsSecLogonSoapStub) new WsSecLogonLocator().getwsSecLogonSoap(u);

        w.setHeader(new WsSecLogonLocator().getServiceName().getNamespaceURI(),"AuthHeader", ah);

...