Signature Class
NOTE: This Class is now obsolete.
Represents a signature as defined by the XML signature specification. This class cannot be inherited.
Namespace: Microsoft.Web.Services2.Security
Assembly: Microsoft.Web.Services2 (in microsoft.web.services2.dll)
Usage
'Usage
Dim token As SecurityToken
Dim signature1 As New Signature(token)
Syntax
'Declaration
NotInheritable Public Class Signature
Inherits MessageSignature
public sealed class Signature : MessageSignature
public sealed ref class Signature : public MessageSignature
public final class Signature extends MessageSignature
public class Signature extends MessageSignature
Example
The following code example signs a SOAP message using an X.509 certificate. The GetSecurityToken
method retrieves an X.509 certificate from the certificate store. To view the code for the GetSecurityToken
method, see How to: Sign a SOAP Message Using an X.509 Certificate.
' Gets the SoapContext for the SOAP request that is to be sent
' to the XML Web service.
Dim svc As New Service1Wse
Dim requestContext As SoapContext = svc.RequestSoapContext
' Gets the X.509 certificate for signing the SOAP message.
Dim signatureToken As X509SecurityToken = GetSecurityToken(True)
If signatureToken Is Nothing Then
Return
End If
' Adds the X.509 certificate to the WS-Security header.
requestContext.Security.Tokens.Add(signatureToken)
' Signs the SOAP message using the X.509 certifcate.
requestContext.Security.Elements.Add(New MessageSignature(signatureToken))
' Sets the TTL to one minute.
requestContext.Security.Timestamp.TtlInSeconds = 60
' Makes the SOAP request to the XML Web service.
textBoxResult.Text = svc.AddNumbers(a, b).ToString()
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub 'Sign
// Gets the SoapContext for the SOAP request that is to be sent
// to the XML Web service.
Service1Wse svc = new Service1Wse();
SoapContext requestContext = svc.RequestSoapContext;
// Gets the X.509 certificate for signing the SOAP message.
X509SecurityToken signatureToken = GetSecurityToken(true);
if (signatureToken == null)
{
return;
}
// Adds the X.509 certificate to the WS-Security header.
requestContext.Security.Tokens.Add(signatureToken);
// Signs the SOAP message using the X.509 certifcate.
requestContext.Security.Elements.Add(new MessageSignature(signatureToken));
// Sets the TTL to one minute.
requestContext.Security.Timestamp.TtlInSeconds = 60;
// Makes the SOAP request to the XML Web service.
textBoxResult.Text = svc.AddNumbers(a,b).ToString() ;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
Remarks
This class implements the ISecurityElement interface and represents a single signature within a security header. It is created with a SecurityToken that supports signing messages.
Inheritance Hierarchy
System.Object
Microsoft.Web.Services2.Security.MessageSignature
Microsoft.Web.Services2.Security.Signature
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
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
See Also
Reference
Microsoft.Web.Services2.Security Namespace
Other Resources
Signature Members
ms819963(v=msdn.10).md
ms824701(v=msdn.10).md