This documentation is archived and is not being maintained.

SoapHeader.Actor Property

Gets or sets the recipient of the SOAP header.

[Visual Basic]
Public Property Actor As String
[C#]
public string Actor {get; set;}
[C++]
public: __property String* get_Actor();
public: __property void set_Actor(String*);
[JScript]
public function get Actor() : String;
public function set Actor(String);

Property Value

The recipient of the SOAP header. The default is an empty string ("").

Remarks

To set the recipient of a SOAP header, set the Actor property. Regardless of the version of the SOAP protocol used to communicate with an XML Web service, the .NET Framework automatically generates the SOAP message specific to the version of the SOAP protocol. Specifically, the XML element and XML namespace representing the recipient differ for the two versions.

XML Web services receiving the SOAP header can get the intended recipient by getting either the Role or Actor properties.

The recipient(s) for the Body element and each of the SOAP headers within the Header element of a SOAP message need not be the same. If a Header element exists in the SOAP message, it represents additional data that can be sent to and from the XML Web service method or an intermediary. The recipient of that data, known as the SOAP Actor in version 1.1, can be a different URI than the URI for the XML Web service method.

For more information on the SOAP actor attribute, see the SOAP specification at http://www.w3.org/TR/SOAP/.

Example

[Visual Basic, C#, C++] The following XML Web service client calls the MyWebMethod XML Web service method after creating a custom SOAP header of type MyHeader and setting the Actor property to http://www.contoso.com/MySoapHeaderHandler.

[Visual Basic] 
Imports System

Public Class Sample
    
    Public Shared Sub Main()
        Dim ws As New MyWebService()

        Try
            Dim customHeader As New MyHeader1()

            customHeader.MyValue = "Header Value for MyValue"
            customHeader.Actor = "http://www.contoso.com/MySoapHeaderHandler"

            ws.myHeader = customHeader

        Dim results As Integer

            results = ws.MyWebMethod(3,5)
        Catch e As Exception
            Console.WriteLine("Exception: {0}", e.ToString())
        End Try
    End Sub
End Class


[C#] 
using System;

public class Sample {
    
    public static void Main() {
        MyWebService ws = new MyWebService();

        try {
            MyHeader customHeader = new MyHeader();
            customHeader.MyValue = "Header Value for MyValue";
            customHeader.Actor = "http://www.contoso.com/MySoapHeaderHandler";
            ws.myHeader = customHeader;
            
        int results = ws.MyWebMethod(3,5);
        }
        catch (Exception e) {
            Console.WriteLine ("Exception: {0}", e.ToString());
        }
    }
}


[C++] 
int main() {
   MyWebService* ws = new MyWebService();

   try {
      MyHeader* customHeader = new MyHeader();
      customHeader->MyValue = S"Header Value for MyValue";
      customHeader->Actor = S"http://www.contoso.com/MySoapHeaderHandler";
      ws->myHeader = customHeader;

      int results = ws->MyWebMethod(3,5);
   }
   catch (Exception* e) {
      Console::WriteLine (S"Exception: {0}", e);
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

SoapHeader Class | SoapHeader Members | System.Web.Services.Protocols Namespace

Show: