SoapHeader.Actor 属性

定义

获取或设置 SOAP 标头的接收者。Gets or sets the recipient of the SOAP header.

public:
 property System::String ^ Actor { System::String ^ get(); void set(System::String ^ value); };
public string Actor { get; set; }
member this.Actor : string with get, set
Public Property Actor As String

属性值

SOAP 标头的接收者。The recipient of the SOAP header. 默认值为空字符串("")。The default is an empty string ("").

示例

以下 XML Web service 客户端在创建MyWebMethod类型MyHeader的自定义 SOAP 标头并将Actor属性设置为http://www.contoso.com/MySoapHeaderHandler后, 将调用 XML Web service 方法。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.

int main()
{
   MyWebService^ ws = gcnew MyWebService;
   try
   {
      MyHeader^ customHeader = gcnew 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 );
   }

}

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());
        }
    }
}

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

注解

若要设置 SOAP 标头的接收方, 请Actor设置属性。To set the recipient of a SOAP header, set the Actor property. 无论用于与 XML Web service 进行通信的 SOAP 协议的版本如何, .NET Framework 都会自动生成特定于 SOAP 协议版本的 SOAP 消息。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. 具体而言, 这两个版本的表示接收者的 XML 元素和 XML 命名空间不同。Specifically, the XML element and XML namespace representing the recipient differ for the two versions.

接收 SOAP 标头的 XML Web services 可以通过获取RoleActor属性来获取目标接收方。XML Web services receiving the SOAP header can get the intended recipient by getting either the Role or Actor properties.

Soap 消息的Body Header元素内的元素和每个 soap 标头的接收者不必相同。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. 如果 SOAP 消息中存在元素,则它表示可与XMLWebservice方法或中介一起发送和的附加数据。HeaderIf 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. 在版本1.1 中, 该数据的接收方Actor称为 SOAP, 可以是与 XML Web service 方法的 uri 不同的 uri。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.

有关 soap actor特性的详细信息, 请参阅soap规范。For more information on the SOAP actor attribute, see the SOAP specification.

适用于