41
Views
4
Comments
SOAP SecurityHeaders
Question
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?
2011-08-23 22-04-05
Tiago Simões
Staff
Hi João,

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

Cheers,
Tiago Simões
UserImage.jpg
João Mendes
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="https://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. 
2025-09-25 08-38-29
Rodrigo Castelo
Staff
Hi João,


Did you try using the SetWebReferenceCredencials action of the extension?


Cheers,
2013-06-13 01-27-39
José Caldeira
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=""https://schemas.xmlsoap.org/soap/envelope/""
xmlns:wsse=""https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"">
<wsu:Timestamp xmlns:wsu=""https://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=""https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"">
<wsse:Username>user</wsse:Username>
<wsse:Password Type=""https://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
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.