SOAP SecurityHeaders

SOAP SecurityHeaders

  
I am trying to add a Web Reference to a webservice that have a Security Header. How can i pass the values to the security header?
Hi João,

Take a look into the EnhancedWebReferences extension (it allows you to add soap headers)

Cheers,
Tiago Simões
I already looked to that extension, but i'm not being able to use it. This is what i need to pass to the request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="endereço">
   <soapenv:Header>
      <ws:Locale>?</ws:Locale>
      <ws:Security>
         <username>?</username>
         <password>?</password>
      </ws:Security>

   </soapenv:Header>
   <soapenv:Body>
      <ws:GetLocales/>
   </soapenv:Body>
</soapenv:Envelope>

I think that Security and Locale are classes from the webservice that i'm not being able to access. 
Hi João,


Did you try using the SetWebReferenceCredencials action of the extension?


Cheers,
Hi João,

In the past I had the same problem, and usually it is hard to find what the webservice needs to receive in the soap header. Here's the code I had to use in my test:
"<wsse:Security s:mustUnderstand=""1""
xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/""
xmlns:wsse=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"">
<wsu:Timestamp xmlns:wsu=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"">
<wsu:Created>" + Replace(CurrDateTime(), " ", "T") +"</wsu:Created>
<wsu:Expires>" + Replace(AddHours(CurrDateTime(), 1), " ", "T") +"</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken xmlns:wsu=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"">
<wsse:Username>user</wsse:Username>
<wsse:Password Type=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"">password</wsse:Password>
<wsse:Nonce></wsse:Nonce>
</wsse:UsernameToken>
</wsse:Security>"
Probably you'll need to remove the Type in the password element, and to change the datetime format. I just needed to set the soap header with this, and it was working. Hope this solution works for you.


Cheers,
José Caldeira