SoapHeaderAttributeとは? わかりやすく解説

SoapHeaderAttribute クラス

この属性は、XML Web サービス メソッドまたは XML Web サービス クライアントに適用され、XML Web サービス メソッドまたは XML Web サービス クライアントが処理できる SOAP ヘッダーを指定します。このクラスは継承できません。

名前空間: System.Web.Services.Protocols
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple:=True)> _
Public NotInheritable Class
 SoapHeaderAttribute
    Inherits Attribute
Dim instance As SoapHeaderAttribute
[AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple=true)]
 
public sealed class SoapHeaderAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method, AllowMultiple=true)]
 
public ref class SoapHeaderAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple=true)
 */ 
public final class SoapHeaderAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple=true)
 
public final class SoapHeaderAttribute extends
 Attribute
解説解説
使用例使用例

MyHeader 型の 1 つの SoapHeader を定義する MyWebService XML Web サービスを次に示します。Hello XML Web サービス メソッドは、クライアントがこの SoapHeader で XML Web サービス メソッドを呼び出すことを要求します。Hello XML Web サービスは、MyHeader 以外の任意の SOAP ヘッダーも受け取ります。

<%@ WebService Language="VB" Class="MyWebService"%>
Imports System.Web.Services
Imports System.Web.Services.Protocols

' Define a SOAP header by deriving from the SoapHeader base class.
' The header contains just one string value.
Public Class MyHeader
    Inherits SoapHeader
    Public MyValue As String
End Class

Public Class MyWebService
    ' Member variable to receive the contents of the MyHeader SoapHeader.
    Public myHeader As MyHeader
    
    ' Member variable to receive all headers other than MyHeader.
    Public unknownHeaders() As SoapUnknownHeader
    
    ' Receive any SOAP headers other than MyHeader.
    <WebMethod, _
        SoapHeader("myHeader", Direction := SoapHeaderDirection.InOut),
 _
        SoapHeader("unknownHeaders")> _
    Public Sub Hello()        
        
        ' Process the MyHeader SoapHeader.
        If myHeader.MyValue = "Some string"
 Then
            ' Process the header.
        End If 
        Dim header As SoapHeader
        For Each header In
  unknownHeaders
            ' Perform some processing on header
            ' For those headers that cannot be processed, 
            ' set the DidUnderstand to false.
            header.DidUnderstand = False
        Next header
    End Sub
End Class

<%@ WebService Language="C#" Class="MyWebService"%>
using System.Web.Services;
using System.Web.Services.Protocols;

// Define a SOAP header by deriving from the SoapHeader base class.
// The header contains just one string value.
public class MyHeader : SoapHeader {
    public string MyValue;
}

public class MyWebService {
    // Member variable to receive the contents of the MyHeader SoapHeader.
    public MyHeader myHeader;

    // Member variable to receive all headers other than MyHeader.
    public SoapUnknownHeader[] unknownHeaders;
 
    [WebMethod]
    [SoapHeader("myHeader", Direction=SoapHeaderDirection.InOut)]

    // Receive any SOAP headers other than MyHeader.
    [SoapHeader("unknownHeaders")]
    public void Hello() {

       // Process the MyHeader SoapHeader.
       if (myHeader.MyValue == "Some string")
 {
          // Process the header.
       }
       foreach (SoapHeader header in unknownHeaders)
 {
           // Perform some processing on header.
           
           // For those headers that cannot be processed,
           // set the DidUnderstand property to false.
           header.DidUnderstand = false;
       }
    }
}

継承階層継承階層
System.Object
   System.Attribute
    System.Web.Services.Protocols.SoapHeaderAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SoapHeaderAttribute メンバ
System.Web.Services.Protocols 名前空間
MemberName
SoapHeader クラス

SoapHeaderAttribute コンストラクタ

SOAP ヘッダーの内容を表す XML Web サービス クラスのメンバを設定して、SoapHeaderAttribute クラスの新しいインスタンスを初期化します。

名前空間: System.Web.Services.Protocols
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文構文

Public Sub New ( _
    memberName As String _
)
Dim memberName As String

Dim instance As New SoapHeaderAttribute(memberName)
public SoapHeaderAttribute (
    string memberName
)
public:
SoapHeaderAttribute (
    String^ memberName
)
public SoapHeaderAttribute (
    String memberName
)
public function SoapHeaderAttribute (
    memberName : String
)

パラメータ

memberName

SOAP ヘッダーの内容を表す XML Web サービス クラスのメンバ。MemberName プロパティはこのパラメータの値に設定されます。

解説解説

XML Web サービス クライアントまたは XML Web サービスは、SoapHeaderAttribute を XML Web サービス クラスの XML Web サービス メソッドまたはプロキシ クラス内の対応するメソッドに適用することにより、特定の XML Web サービス メソッドで処理する SOAP ヘッダーを指定できます。XML Web サービス メソッドが SOAP ヘッダーの内容を受信するには、SoapHeader から派生する Type の XML Web サービス クラスにメンバを追加します。同様に、XML Web サービス クライアントは SoapHeader から派生するプロキシ クラスにメンバを追加します。SoapHeader から派生する Type は、SOAP ヘッダーの内容を表し、SOAP ヘッダーを受信する必要がある XML Web サービスまたは XML Web サービス クライアントの開発者によって作成されます。クラスが作成されると、このコンストラクタの memberName パラメータまたは MemberName プロパティを使用して SOAP ヘッダーの内容を受信するメンバを指定する、XML Web サービス メソッドまたは XML Web サービス クライアント プロキシ クラスの対応するメソッドに SoapHeaderAttribute を適用できます。

XML Web サービス メソッドは、XML Web サービス クラスまたは XML Web サービス プロキシ クラスに複数のメンバを追加し、複数の SoapHeaderAttribute 属性を XML Web サービス メソッドに適用することにより、複数の SOAP ヘッダーを受信できます。

XML Web サービスの書き込み時に不明な SOAP ヘッダーの受信や処理を行うには、メンバの Type を SoapUnknownHeader、SoapHeader、またはどちらかのクラスの配列に指定します。

使用例使用例

MyHeader 型の 1 つの SoapHeader を定義する MyWebService XML Web サービスを次に示します。Hello XML Web サービス メソッドは、myHeader メンバを MemberName プロパティとして指定し、XML Web サービス メソッドに渡された MyHeader SOAP ヘッダーの内容を受け取ります。

Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols

' Define a SOAP header by deriving from the SoapHeader base class.
' The header contains just one string value.
Public Class MyHeader
   Inherits SoapHeader
   Public MyValue As String
End Class 'MyHeader


Public Class MyWebService
   ' Member variable to receive the contents of the MyHeader SOAP header.
   Public myHeader As MyHeader

   
   <WebMethod, _ 
    SoapHeader("myHeader", Direction := SoapHeaderDirection.InOut)>
 _
   Public Sub Hello()

   End Sub 'Hello
End Class 'MyWebService

using System;
using System.Web.Services;
using System.Web.Services.Protocols;

// Define a SOAP header by deriving from the SoapHeader base class.
// The header contains just one string value.
public class MyHeader : SoapHeader {
    public string MyValue;
}

public class MyWebService {
    // Member variable to receive the contents of the MyHeader SOAP
 header.
    public MyHeader myHeader;
 
    [WebMethod]
    [SoapHeader("myHeader", Direction=SoapHeaderDirection.InOut)]
    public void Hello() {
    
    }
}
#using <System.EnterpriseServices.dll>
#using <System.Web.Services.dll>

using namespace System;
using namespace System::Web::Services;
using namespace System::Web::Services::Protocols;

// Define a SOAP header by deriving from the SoapHeader base class.
// The header contains just one string value.
public ref class MyHeader: public
 SoapHeader
{
public:
   String^ MyValue;
};

public ref class MyWebService
{
public:

   // Member variable to receive the contents of the MyHeader SOAP header.
   MyHeader^ myHeader;

   [WebMethod]
   [SoapHeader("myHeader",Direction=SoapHeaderDirection::InOut)]
   void Hello(){}

};

import System.*;
import System.Web.Services.*;
import System.Web.Services.Protocols.*;

// Define a SOAP header by deriving from the SoapHeader base class.
// The header contains just one string value.
public class MyHeader extends SoapHeader
{
    public String myValue;
} //MyHeader

public class MyWebService
{
    // Member variable to receive the contents of the MyHeader SOAP
 header.
    public MyHeader myHeader;

    /** @attribute WebMethod()
     */
    /** @attribute SoapHeader("myHeader", Direction = SoapHeaderDirection.InOut)
     */

    public void Hello()
    {
    } //Hello
} //MyWebService
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SoapHeaderAttribute クラス
SoapHeaderAttribute メンバ
System.Web.Services.Protocols 名前空間

SoapHeaderAttribute プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ .NET Compact Framework によるサポート .NET Compact Framework によるサポート .NET Compact Framework によるサポート TypeId  派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。)
参照参照

関連項目

SoapHeaderAttribute クラス
System.Web.Services.Protocols 名前空間
MemberName
SoapHeader クラス

SoapHeaderAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

SoapHeaderAttribute クラス
System.Web.Services.Protocols 名前空間
MemberName
SoapHeader クラス

SoapHeaderAttribute メンバ

この属性は、XML Web サービス メソッドまたは XML Web サービス クライアントに適用され、XML Web サービス メソッドまたは XML Web サービス クライアントが処理できる SOAP ヘッダーを指定します。このクラスは継承できません。

SoapHeaderAttribute データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ .NET Compact Framework によるサポート .NET Compact Framework によるサポート .NET Compact Framework によるサポート TypeId  派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

SoapHeaderAttribute クラス
System.Web.Services.Protocols 名前空間
MemberName
SoapHeader クラス



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「SoapHeaderAttribute」の関連用語

SoapHeaderAttributeのお隣キーワード

   

英語⇒日本語
日本語⇒英語
   



SoapHeaderAttributeのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS