共用方式為


SoapHeader.Actor 屬性

定義

取得或設定 SOAP 標頭的接收者。

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 標頭的收件人。 預設為空字串(“”)。

範例

以下 XML Web 服務用戶端在建立自訂 SOAP 標頭(類型MyHeader)並將屬性設Actorhttp://www.contoso.com/MySoapHeaderHandler後,呼叫 MyWebMethod XML Web 服務方法。

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 。 無論用來與 XML Web 服務通訊的 SOAP 協定版本為何,.NET Framework 都會自動產生與該 SOAP 協定版本相關的 SOAP 訊息。 具體來說,兩個版本的 XML 元素與代表接收者的 XML 命名空間有所不同。

接收 SOAP 標頭的 XML 網路服務可透過取得 RoleActor 屬性來取得預期收件人。

該元素的接收者 Body 與 SOAP 訊息中元素內 Header 的每個 SOAP 標頭不必相同。 若 Header SOAP 訊息中存在元素,代表可與 XML Web 服務方法或中介機構傳送的額外資料。 該資料的接收者,在版本 1.1 中稱為 SOAP Actor ,可以是與 XML Web 服務方法的 URI 不同的 URI。

欲了解更多 SOAP actor 屬性的資訊,請參閱 SOAP 規範。

適用於