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
Christian Monje Marcos 15Christian Monje Marcos 15 

web service security integration

Hi. 

I'm doing an integration with an external service (web service), I generated the apex classes through WSDL2Apex until here everything goes well, the problem is that the WS has a web service security header and I do not know how to add it. The header I have to add is the following:

   <soapenv:Header>
 <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" wsse:mustUnderstand="1">
     <wsse:UsernameToken>
         <wsse:Username>XXXXX</wsse:Username>
         <wsse:Password>XXXX</wsse:Password>
        </wsse:UsernameToken>
   </wsse:Security>
   </soapenv:Header>


If someone has done something similar and can help me would be greatly appreciated.
Thanks in advance for any help.
NagendraNagendra (Salesforce Developers) 
Hi Christian,

Sorry for this issue you are facing.

Salesforce, unfortunately, does not support setting SOAP headers (like WS-Security) that are not explicitly included in the WSDL markup. You can set HTTP headers of course, but not SOAP headers.

There may be a workaround though - you should be able to manually insert the Web Service Security headers into the SOAP payload. 

Thanks,
Nagendra
Christian Monje Marcos 15Christian Monje Marcos 15
Hi Nagendra,

Can you tell me or help me to do it? I've been researching about it and the links I've seen and reviewed do not make it very clear how to manually make the header of the call to WS.

Thank you very much for answering my question.
prem jonnala 11prem jonnala 11
There is workaround , Please see the following link it has the information.
 
https://salesforce.stackexchange.com/questions/178961/issue-with-soap-header-created-via-apex
 
Christian Monje Marcos 15Christian Monje Marcos 15
Hi. 
 
Finally I have found a solution generating the XML to send to WS through DOM.Document and creating the headers I need to perform the integration.

Regards
kevin garcia 10kevin garcia 10
Hi Christian !! Can you tell me how you solved this... I have the same problem with wsse:Security and I dont find any soluton...
Regards