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
jwolfjwolf 

Setting soap header

I'm trying to connect to a soap web service which implicitly defines a required soap header. That part of the WSDL looks like this:
 <s0:Policy s1:Id="Auth.xml">
    <wssp:Identity xmlns:wssp="http://www.bea.com/wls90/security/policy">
      <wssp:SupportedTokens>
        </wssp:SecurityToken>
      </wssp:SupportedTokens>
    </wssp:Identity>
  </s0:Policy>
  <wsp:UsingPolicy s2:Required="true"/>
In order to call this service, I need to set my soap header to look like this:
<soapenv:Header>
<wsse:UsernameToken wsu:Id="UsernameToken-3" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>someusername</wsse:Username>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
So, wsdl2apex doesn't create these elements when generating the apex class. As far as I can see its not possible to set arbitrary soap headers from within apex. At this point I've tried to modify the WSDL to make this explicit and I've tried to modify the generated class to produce the proper header but I've had no luck up to this point. Anyone have any ideas? Is this possible from within apex?

_Prasu__Prasu_

AFAIK, its is possible to set the headers. WSDL2Apex must have created the inner classes for header. Or something must be wrong with the WSDL.

qcmikeqcmike

I have a similar issue. DId you ever figure out how this was done?

jwolfjwolf

As a workaround, I ended up manually making the soap request.

jojoforcejojoforce

how do you manually create a SOAP request?