HttpMethodAttribute Sınıf
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
HTTP-GET veya HTTP-POST kullanarak bir XML Web hizmeti istemcisine bu özniteliği 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)>]
type HttpMethodAttribute = class
inherit Attribute
Public NotInheritable Class HttpMethodAttribute
Inherits Attribute
- Devralma
- Ö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 ReturnFormatteriçin ParameterFormatter doğru türleri otomatik olarak sağlar ve proxy sınıfının öğesinden 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 XmlReturnReader ve ParameterFormatter olarak ayarlanmalıdır UrlParameterWriter. HTTP-POST kullanarak XML Web hizmetini çağıran XML Web hizmeti istemcileri ve ReturnFormatterXmlReturnReaderolarak ParameterFormatter ayarlanmalıdırHtmlFormParameterWriter.
Oluşturucular
| Name | Description |
|---|---|
| HttpMethodAttribute() |
HttpMethodAttribute sınıfının yeni bir örneğini başlatır. |
| HttpMethodAttribute(Type, Type) |
öğesinin yeni bir örneğini HttpMethodAttributebaşlatır. |
Özellikler
| Name | Description |
|---|---|
| ParameterFormatter |
XML Web hizmeti istemcisinden XML Web hizmeti yöntemine gönderilen parametreleri seri hale getiren bir Type alır veya ayarlar. |
| ReturnFormatter |
XML Web hizmeti yönteminden yanıtı seri durumdan çıkartan 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
| Name | Description |
|---|---|
| Equals(Object) |
Bu örneğin belirtilen bir nesneye eşit olup olmadığını gösteren bir değer döndürür. (Devralındığı yer: Attribute) |
| GetHashCode() |
Bu örneğin karma kodunu döndürür. (Devralındığı yer: Attribute) |
| GetType() |
Geçerli örneğin Type 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 Objectbasit bir kopyasını oluşturur. (Devralındığı yer: Object) |
| ToString() |
Geçerli nesneyi temsil eden bir dize döndürür. (Devralındığı yer: Object) |
Belirtik Arabirim Kullanımları
| Name | Description |
|---|---|
| _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 kullanıma sunulan özelliklere ve yöntemlere erişim sağlar. (Devralındığı yer: Attribute) |