How to add the <soap: Header> tag? WSDL does not appear with this data
I need to add something like this to my post:
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soap:mustUnderstand="1">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="unt_Z1k4LnxEmBzzKuPP">
<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 EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">iNs+LF1iwwPU2AMer8uU6NKY9tfzgYqMTaP3mIEgoK0=</wsse:Nonce>
<wsu:Created>2012-04-22T11:57:30Z</wsu:Created>
</wsse:UsernameToken>
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>2012-04-22T11:57:30Z</wsu:Created>
<wsu:Expires>2012-04-22T11:58:30Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>
I am calling a web service that returns a 500 error response, which basically means that it cannot authenticate. I suggest that I skip this information from the message, even if I have an authentication header in the message. Could this happen?
How to add a WS-Security header to a message and add all this data to the code? I added the service using Add Web Link in Visual Studio.
Thank.
+3
1 answer
, .NET 3.5 .NET 2.0, WSE 3.0, VS, WSE.
- (, Myservice MyServiceWse). SoapHttpClient, - WCF WebServicesClientProtocol.
, , - ASMX, WS-Security.
:
MyServiceWse client = new MyServiceWse();
UsernameToken token = new UsernameToken(userName, password, PasswordOption.SendPlainText); // or what service specs rquired, other than plaintext.
client.RequestSoapContext.Security.Tokens.Add(token);
client.RequestSoapContext.Security.Timestamp.TtlInSeconds = 60;
client.YourMethod();
API, Microsoft VS 2005, Stream , , , ...
Add Reference, Add Web Reference WSE, WS-Security, UsernameToken, TimeStamp Created, Expired ..
, .
P.S. .
+2