HttpMethodAttribute Sınıf

Tanım

BU özniteliği HTTP-GET veya HTTP-POST kullanarak bir XML Web hizmeti istemcisine uygulamak, XML Web hizmeti yöntemine gönderilen parametreleri seri hale getiren türleri ayarlar ve YANıTı XML Web hizmeti yönteminden okur. Bu sınıf devralınamaz.

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
Devralma
HttpMethodAttribute
Öznitelikler

Örnekler

Aşağıdaki örnek, HTTP-POST kullanarak XML Web hizmeti yardımcı programını çağırmak için Wsdl.exe yardımcı programı tarafından oluşturulan bir ara sunucu sınıfıdır. Wsdl.exe ve için ReturnFormatter ParameterFormatterdoğru türleri otomatik olarak sağlar ve ara sunucunun sınıfından HttpPostClientProtocoldevralacağını belirtir.

[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

Açıklamalar

XML Web hizmeti istemcisi HTTP-GET kullanarak bir XML Web hizmeti yöntemini çağırırsa, ReturnFormatter olarak ve XmlReturnReader ParameterFormatter olarak ayarlanmalıdır UrlParameterWriter. HTTP-POST kullanarak bir XML Web hizmetini çağıran XML Web hizmeti istemcileri ve ParameterFormatter olarak ayarlanmalıdır ReturnFormatter XmlReturnReader.HtmlFormParameterWriter

Oluşturucular

HttpMethodAttribute()

HttpMethodAttribute sınıfının yeni bir örneğini başlatır.

HttpMethodAttribute(Type, Type)

Yeni bir HttpMethodAttribute örneğini başlatır.

Özellikler

ParameterFormatter

XML Type Web hizmeti istemcisinden XML Web hizmeti yöntemine gönderilen parametreleri seri hale getiren bir alır veya ayarlar.

ReturnFormatter

XML Web hizmeti yönteminden yanıtı seri durumdan çıkaran bir alır veya ayarlar Type .

TypeId

Türetilmiş bir sınıfta uygulandığında, bu Attributeiçin benzersiz bir tanımlayıcı alır.

(Devralındığı yer: Attribute)

Yöntemler

Equals(Object)

Bu örneğin belirtilen bir nesneye eşit olup olmadığını gösteren bir değeri döndürür.

(Devralındığı yer: Attribute)
GetHashCode()

Bu örneğe ilişkin karma kodu döndürür.

(Devralındığı yer: Attribute)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
IsDefaultAttribute()

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin değerinin türetilmiş sınıf için varsayılan değer olup olmadığını gösterir.

(Devralındığı yer: Attribute)
Match(Object)

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin belirtilen bir nesneye eşit olup olmadığını gösteren bir değer döndürür.

(Devralındığı yer: Attribute)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Belirtik Arabirim Kullanımları

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

Bir ad kümesini karşılık gelen bir dağıtma tanımlayıcısı kümesine eşler.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Bir arabirimin tür bilgilerini almak için kullanılabilecek bir nesnenin tür bilgilerini alır.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Bir nesnenin sağladığı tür bilgisi arabirimlerinin sayısını alır (0 ya da 1).

(Devralındığı yer: Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Bir nesne tarafından sunulan özelliklere ve yöntemlere erişim sağlar.

(Devralındığı yer: Attribute)

Şunlara uygulanır

Ayrıca bkz.