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

HttpMethodAttribute クラス

HTTP-GET または HTTP-POST を使用する XML Web サービス クライアントにこの属性を適用し、XML Web サービスに送信されたパラメータをシリアル化する型、および XML Web サービス メソッドから応答を読み取る型を設定します。このクラスは継承できません。

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

<AttributeUsageAttribute(AttributeTargets.Method)> _
Public NotInheritable Class
 HttpMethodAttribute
    Inherits Attribute
Dim instance As HttpMethodAttribute
[AttributeUsageAttribute(AttributeTargets.Method)] 
public sealed class HttpMethodAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method)] 
public ref class HttpMethodAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Method) */ 
public final class HttpMethodAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.Method) 
public final class HttpMethodAttribute extends
 Attribute
解説解説

XML Web サービス クライアントが HTTP-GET を使用して XML Web サービス メソッドを呼び出す場合は、ReturnFormatter を XmlReturnReader に設定し、ParameterFormatter を UrlParameterWriter に設定する必要があります。HTTP-POST を使用して XML Web サービスを呼び出す XML Web サービス クライアントでは、ReturnFormatter を XmlReturnReader に設定し、ParameterFormatter を HtmlFormParameterWriter に設定する必要があります。

使用例使用例

HTTP-POST を使用して XML Web サービス ユーティリティを呼び出すために、Wsdl.exe ユーティリティによって生成されるプロキシ クラスの例を次に示します。Wsdl.exe は、ReturnFormatter および ParameterFormatter に対応する適切な型を自動的に指定し、またプロキシ クラスが HttpPostClientProtocol から継承することも指定します。

Public Class MyUser
    Inherits System.Web.Services.Protocols.HttpPostClientProtocol
    
    
    Public Sub New()
        Me.Url = "http://www.contoso.com/username.asmx"
    End Sub 'New
    
    <HttpMethodAttribute(GetType(XmlReturnReader), GetType(HtmlFormParameterWriter))>
 _
    Public Function GetUserName() As
 UserName
        Return CType(Me.Invoke("GetUserName",
 Me.Url + "/GetUserName", New
 Object(0) {}), UserName)
    End Function 'GetUserName
    
    
    Public Function BeginGetUserName(callback
 As System.AsyncCallback, asyncState As Object)
 As System.IAsyncResult
        Return Me.BeginInvoke("GetUserName",
 Me.Url + "/GetUserName", New
 Object(0) {}, callback, asyncState)
    End Function 'BeginGetUserName
    
    
    Public Function EndGetUserName(asyncResult
 As System.IAsyncResult) As UserName
        Return CType(Me.EndInvoke(asyncResult),
 UserName)
    End Function 'EndGetUserName
End Class 'MyUser

<XmlRootAttribute(Namespace := "http://tempuri.org/",
 IsNullable := True)> _
Public Class UserName
    Public Name As String
    Public Domain As String

End Class 'UserName
public class MyUser : System.Web.Services.Protocols.HttpPostClientProtocol
 {
    
    public MyUser() {
        this.Url = "http://www.contoso.com/username.asmx";
    }
    
    [System.Web.Services.Protocols.HttpMethodAttribute(typeof(System.Web.Services.Protocols.XmlReturnReader),
 typeof(System.Web.Services.Protocols.HtmlFormParameterWriter))]
    public UserName GetUserName() {
        return ((UserName)(this.Invoke("GetUserName",
 (this.Url + "/GetUserName"), new
 object[0])));
    }
    
    public System.IAsyncResult BeginGetUserName(System.AsyncCallback
 callback, object asyncState) {
        return this.BeginInvoke("GetUserName",
 (this.Url + "/GetUserName"), new
 object[0], callback, asyncState);
    }
    
    public UserName EndGetUserName(System.IAsyncResult asyncResult)
 {
        return ((UserName)(this.EndInvoke(asyncResult)));
    }
}

[System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/",
 IsNullable=true)]
public class UserName {
    
    public string Name;
    
    public string Domain;
}
   
[System::Xml::Serialization::XmlRootAttribute(Namespace="http://tempuri.org/"
,IsNullable=true)]
public ref class UserName
{
public:
   String^ Name;
   String^ Domain;
};

public ref class MyUser: public
 System::Web::Services::Protocols::HttpPostClientProtocol
{
public:
   MyUser()
   {
      this->Url = "http://www.contoso.com/username.asmx";
   }

   [System::Web::Services::Protocols::HttpMethodAttribute(System::Web::Services::Protocols::XmlReturnReader::typeid
,System::Web::Services::Protocols::HtmlFormParameterWriter::typeid)]
   UserName^ GetUserName()
   {
      return (dynamic_cast<UserName^>(this->Invoke(
 "GetUserName", (String::Concat( this->Url, "/GetUserName"
 )), gcnew array<Object^>(0) )));
   }

   System::IAsyncResult^ BeginGetUserName( System::AsyncCallback^ callback, Object^
 asyncState )
   {
      return this->BeginInvoke( "GetUserName",
 (String::Concat( this->Url, "/GetUserName" )),
 gcnew array<Object^>(0), callback, asyncState );
   }

   UserName^ EndGetUserName( System::IAsyncResult^ asyncResult )
   {
      return (dynamic_cast<UserName^>(this->EndInvoke(
 asyncResult )));
   }
};
public class MyUser extends System.Web.Services.Protocols.HttpPostClientProtocol
{
    public MyUser()
    {
        this.set_Url("http://www.contoso.com/username.asmx");
    } //MyUser

    /** @attribute System.Web.Services.Protocols.HttpMethodAttribute
        (System.Web.Services.Protocols.XmlReturnReader .class
,
        System.Web.Services.Protocols.HtmlFormParameterWriter .class)
     */
    public UserName GetUserName()
    {
        return ((UserName)(this.Invoke("GetUserName",
 this.get_Url()
            + "/GetUserName", new Object[0])));
    } //GetUserName

    public System.IAsyncResult BeginGetUserName(System.AsyncCallback
 callback,
        Object asyncState)
    {
        return this.BeginInvoke("GetUserName",
 this.get_Url()
            + "/GetUserName", new Object[0], callback,
 asyncState);
    } //BeginGetUserName

    public UserName EndGetUserName(System.IAsyncResult asyncResult)
    {
        return ((UserName)(this.EndInvoke(asyncResult)));
    } //EndGetUserName
} //MyUser

/** @attribute System.Xml.Serialization.XmlRootAttribute
    (Namespace = "http://tempuri.org/", IsNullable = true)
 */
public class UserName
{
    public String name;
    public String domain;
} //UserName
class MyUser extends System.Web.Services.Protocols.HttpPostClientProtocol{

    function MyUser(){
        this.Url = "http://www.contoso.com/username.asmx"
    } //New

    public HttpMethodAttribute(XmlReturnReader, HtmlFormParameterWriter)
    function GetUserName() : UserName{
        return UserName(this.Invoke("GetUserName",
 this.Url + "/GetUserName", new
 Object[0]))
    } //GetUserName

    function BeginGetUserName(callback : System.AsyncCallback,
 asyncState : Object) : System.IAsyncResult{
        return this.BeginInvoke("GetUserName",
 this.Url + "/GetUserName", new
 Object[0], callback, asyncState)
    } //BeginGetUserName

    function EndGetUserName(asyncResult : System.IAsyncResult)
 : UserName{
        return UserName(this.EndInvoke(asyncResult))
    } //EndGetUserName
} //MyUser

public XmlRootAttribute(Namespace = "http://tempuri.org/",
 IsNullable = true)
class UserName{
    var Name : String
    var Domain : String

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

HttpMethodAttribute コンストラクタ ()


HttpMethodAttribute コンストラクタ (Type, Type)

HttpMethodAttribute の新しいインスタンスを初期化します。

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

Public Sub New ( _
    returnFormatter As Type, _
    parameterFormatter As Type _
)
Dim returnFormatter As Type
Dim parameterFormatter As Type

Dim instance As New HttpMethodAttribute(returnFormatter,
 parameterFormatter)
public HttpMethodAttribute (
    Type returnFormatter,
    Type parameterFormatter
)
public:
HttpMethodAttribute (
    Type^ returnFormatter, 
    Type^ parameterFormatter
)
public HttpMethodAttribute (
    Type returnFormatter, 
    Type parameterFormatter
)
public function HttpMethodAttribute (
    returnFormatter : Type, 
    parameterFormatter : Type
)

パラメータ

returnFormatter

ReturnFormatter プロパティを、XML Web サービス メソッドからの応答を逆シリアル化する Type に初期化します。

parameterFormatter

ParameterFormatter プロパティを、XML Web サービス クライアントから XML Web サービス メソッドに送信されたパラメータをシリアル化する Type に初期化します。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HttpMethodAttribute クラス
HttpMethodAttribute メンバ
System.Web.Services.Protocols 名前空間

HttpMethodAttribute コンストラクタ

HttpMethodAttribute クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
HttpMethodAttribute () HttpMethodAttribute クラスの新しいインスタンスを初期化します。
HttpMethodAttribute (Type, Type) HttpMethodAttribute の新しいインスタンスを初期化します。
参照参照

関連項目

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

HttpMethodAttribute プロパティ


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

参照参照

関連項目

HttpMethodAttribute クラス
System.Web.Services.Protocols 名前空間
SoapDocumentMethodAttribute
SoapRpcMethodAttribute

HttpMethodAttribute メソッド


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

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

関連項目

HttpMethodAttribute クラス
System.Web.Services.Protocols 名前空間
SoapDocumentMethodAttribute
SoapRpcMethodAttribute

HttpMethodAttribute メンバ

HTTP-GET または HTTP-POST を使用する XML Web サービス クライアントにこの属性を適用し、XML Web サービスに送信されたパラメータをシリアル化する型、および XML Web サービス メソッドから応答を読み取る型を設定します。このクラスは継承できません。

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


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

関連項目

HttpMethodAttribute クラス
System.Web.Services.Protocols 名前空間
SoapDocumentMethodAttribute
SoapRpcMethodAttribute



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「HttpMethodAttribute」の関連用語

HttpMethodAttributeのお隣キーワード
検索ランキング

   

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



HttpMethodAttributeのページの著作権

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

©2026 GRAS Group, Inc.RSS