HttpMethodAttribute クラス

定義

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

public ref class HttpMethodAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class HttpMethodAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public sealed class HttpMethodAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type HttpMethodAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)>]
type HttpMethodAttribute = class
    inherit Attribute
Public NotInheritable Class HttpMethodAttribute
Inherits Attribute
継承
HttpMethodAttribute
属性

次の例は、HTTP-POST を使用して XML Web サービス ユーティリティを呼び出すためのWsdl.exe ユーティリティによって生成されるプロキシ クラスです。 Wsdl.exeは自動的に正しい型 ReturnFormatter を提供し ParameterFormatter、プロキシ クラスの継承を HttpPostClientProtocol指定します。

[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 : 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;
}
Public Class MyUser
    Inherits System.Web.Services.Protocols.HttpPostClientProtocol
    
    
    Public Sub New()
        Me.Url = "http://www.contoso.com/username.asmx"
    End Sub
    
    <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

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

End Class

注釈

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

コンストラクター

HttpMethodAttribute()

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

HttpMethodAttribute(Type, Type)

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

プロパティ

ParameterFormatter

XML Web サービス クライアントから XML Web サービス メソッドへ送信されたパラメーターをシリアル化する、Type を取得または設定します。

ReturnFormatter

XML Web サービス メソッドからの応答を逆シリアル化する Type を取得または設定します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

こちらもご覧ください