SoapHeaderAttribute クラス
アセンブリ: System.Web.Services (system.web.services.dll 内)

<AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple:=True)> _ Public NotInheritable Class SoapHeaderAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple=true)] public sealed class SoapHeaderAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method, AllowMultiple=true)] public ref class SoapHeaderAttribute sealed : public 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.Attribute
System.Web.Services.Protocols.SoapHeaderAttribute


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SoapHeaderAttribute クラスのページへのリンク