MessageSignature Class

Represents an XML signature object that is used to create digital signatures.

Namespace: Microsoft.Web.Services2.Security
Assembly: Microsoft.Web.Services2 (in microsoft.web.services2.dll)

Usage

'Usage
Dim messageSignature1 As New MessageSignature()

Syntax

'Declaration
Public Class MessageSignature
    Implements IXmlElement, ISecurityElement
public class MessageSignature : IXmlElement, ISecurityElement
public ref class MessageSignature : public IXmlElement, ISecurityElement
public class MessageSignature implements IXmlElement, ISecurityElement
public class MessageSignature implements IXmlElement, , ISecurityElement

Example

        ' 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, and contains a valid key assigned to the Microsoft.Web.Services2.Security.Tokens.SecurityToken.Key property.

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

MessageSignature Members
ms819963(v=msdn.10).md
ms824701(v=msdn.10).md
ms819927(v=msdn.10).md
ms824628(v=msdn.10).md