PasswordOption Enumeration
Specifies how passwords contained in a SOAP message are sent.
Namespace: Microsoft.Web.Services2.Security.Tokens
Assembly: Microsoft.Web.Services2 (in microsoft.web.services2.dll)
Usage
'Usage
Dim passwordOption1 As PasswordOption = PasswordOption.SendHashed
Syntax
'Declaration
Public Enum PasswordOption
public enum PasswordOption
public enum class PasswordOption
public enum PasswordOption
public enum PasswordOption
Example
The following code example signs a SOAP message using a UsernameToken, specifying that the SHA-1 hash of the password be sent in the SOAP message.
' Create a UsernameToken security token.
Dim userToken As UsernameToken
userToken = New UsernameToken(username, passwordEquivalent, PasswordOption.SendHashed)
Try
' Create a new instance of the proxy class.
Dim serviceProxy As New AddNumbersWse
' Get the SoapContext associated with the SOAP request.
Dim requestContext As SoapContext = serviceProxy.RequestSoapContext
' Set the period of time in which the SOAP request expires to one minute.
requestContext.Security.Timestamp.TtlInSeconds = 60
' Add the UsernameToken token to the SOAP header.
requestContext.Security.Tokens.Add(userToken)
' Sign the SOAP message using the UsernameToken.
requestContext.Security.Elements.Add(New MessageSignature(userToken))
' Call the Web service method.
Dim sum As Integer = serviceProxy.AddInt(a, b)
' If code execution reaches here, the Web service method was
' successfully communicated with.
Dim message As String = String.Format("{0} + {1} = {2}", a, b, sum)
MessageBox.Show(message, "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch se As System.Web.Services.Protocols.SoapException
MessageBox.Show(se.ToString())
Catch ex As Exception
MessageBox.Show("Exception caught while invoking a web service.", ex.Message)
Return
End Try
// Create a UsernameToken security token.
UsernameToken userToken;
userToken = new UsernameToken(username, passwordEquivalent, PasswordOption.SendHashed);
try
{
// Create a new instance of the proxy class.
AddNumbersWse serviceProxy = new AddNumbersWse();
// Get the SoapContext associated with the SOAP request.
SoapContext requestContext = serviceProxy.RequestSoapContext;
// Set the period of time in which the SOAP request expires to one minute.
requestContext.Security.Timestamp.TtlInSeconds = 60;
// Add the UsernameToken token to the SOAP message.
requestContext.Security.Tokens.Add(userToken);
// Sign the SOAP message using the UsernameToken.
requestContext.Security.Elements.Add(new MessageSignature(userToken));
// Call the Web service method.
int sum = serviceProxy.AddInt(a, b);
// If code execution reaches here, the Web service method was
// successfully communicated with.
string message = string.Format("{0} + {1} = {2}", a, b, sum);
MessageBox.Show(message, "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (System.Web.Services.Protocols.SoapException se)
{
MessageBox.Show(se.ToString());
}
catch (Exception ex)
{
MessageBox.Show ("Exception caught while invoking a web service.", ex.Message );
return;
}
Members
Member name | Description |
---|---|
SendHashed | An SHA-1 hash of the password is sent in the SOAP message. |
SendNone | No password is sent in the SOAP message. |
SendPlainText | The password is sent in clear text.When using this option, a secure transport channel such as SSL should be used. |
Remarks
When sending client credentials to an XML Web service using a UsernameToken, the user name and password are sent in the SOAP message. The PasswordOption enumeration specifies how the password is sent in the SOAP message.
Platforms
Development Platforms
Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Longhorn, and Windows 2000
Target Platforms
Windows 2000, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Longhorn, Pocket PC, Windows CE, Smart Phone