次の方法で共有


SoapHeader.Actor プロパティ

SOAP ヘッダーの受信者を取得または設定します。

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

プロパティ値

SOAP ヘッダーの受信者。既定値は空の文字列 ("") です。

解説

SOAP ヘッダーの受信者を設定するには、 Actor プロパティを設定します。XML Web サービスとの通信に使用している SOAP プロトコルのバージョンに関係なく、.NET Framework は、SOAP プロトコルのバージョンに固有の SOAP メッセージを自動的に生成します。具体的には、受信者を表す XML 要素と XML 名前空間が 2 つのバージョンで異なります。

SOAP ヘッダーを受信する XML Web サービスは、 Role プロパティまたは Actor プロパティを参照することによって、対象の受信者を取得できます。

Body 要素の受信者と、SOAP メッセージの Header 要素内の各 SOAP ヘッダーの受信者は同じである必要はありません。SOAP メッセージ内に Header 要素が存在する場合は、XML Web サービス メソッドに渡したり、XML Web サービス メソッドから返されたり、またはその中間物に渡したり、中間物から返される追加データを表します。Version 1.1 の SOAP Actor と呼ばれるこのデータの受信者は、XML Web サービス メソッドの URI と同一の URI である必要はありません。

SOAP actor 属性の詳細については、SOAP の仕様 (http://www.w3.org/TR/SOAP/) を参照してください。

使用例

[Visual Basic, C#, C++] XML Web サービス クライアントが、 MyHeader 型のカスタム SOAP ヘッダーを作成し、 Actor プロパティを https://www.contoso.com/MySoapHeaderHandler に設定した後で、 MyWebMethod XML Web サービス メソッドを呼び出す例を次に示します。

 
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 = "https://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 = "https://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"https://www.contoso.com/MySoapHeaderHandler";
      ws->myHeader = customHeader;

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

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

SoapHeader クラス | SoapHeader メンバ | System.Web.Services.Protocols 名前空間