The WSE 3.0 for .NET enables the developers for creating one or more security credentials that can be added to the SOAP Message.
The following procedure describes how to add one or more security credentials to a SOAP Message.A computer must be configured to accept the SOAP Messages embedded with the security credentials.
Two types of security credentials that can be setup for the computer
- X.509 certificate.
- Username and Password.
You can configure the computer for X.509 certificate by reading the SOAP Messages signed by an X.509 Certificate.
You can also configure the computer for Username Token by validating SOAP Messages signed by Username Token.
Following procedure is To Add a security token to SOAP
1. Open the Web Service Client project
2.Add references to the Microsoft.Web.Services3 and System.Web.Services assemblies.
3. Add a Web Reference to the Web service that is to receive the SOAP message signed with the UsernameToken.
4. Add the folllowing user directives
using System; using System.Collections.Generic; using System.Text; using System.Security.Cryptography.X509Certificates; using Microsoft.Web.Services3; using Microsoft.Web.Services3.Design; using Microsoft.Web.Services3.Security; using Microsoft.Web.Services3.Security.Tokens;
5. Write the following code by overriding the SecureMessage Method in web service.
public override void SecureMessage(SoapEnvelope envelope, Security security) {UsernameToken userToken; userToken = new UsernameToken(userName, userPasswordEquivalent, PasswordOption.SendNone);
// Adds the token to the SOAP header. security.Tokens.Add(userToken);
}
[…] to be routed to so many intermediaries before reaching the receiver. We can address this problem by Adding Security Credentials to SOAP Message.Alternatively we can digitalsign a SOAP Message using […]
Adding Security Credentials to SOAP…
You’ve been kicked (a good thing) – Trackback from DotNetKicks.com…
Hi, is this compatible to .net 3.5? Because I’m trying to consume a java webservice that requires UsernameToken. I’m using asp.net 3.5 as a client.
I can’t find a good solution on the net on how to attach the soapheader with UsernameToken on every web method request.
I hope you can help. Thanks in advance