HttpMethodAttribute.ParameterFormatter 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定 Type,這型別會將 XML Web Service 用戶端傳來的參數序列化至 XML Web Service 方法。
public:
property Type ^ ParameterFormatter { Type ^ get(); void set(Type ^ value); };
public Type ParameterFormatter { get; set; }
member this.ParameterFormatter : Type with get, set
Public Property ParameterFormatter As Type
屬性值
Type,會將 XML Web Service 用戶端傳來的參數序列化至 XML Web Service 方法。 沒有預設值。
範例
此範例是由使用 HTTP-GET 之 XML Web 服務用戶端的 Wsdl.exe 公用程式所產生的 Proxy 類別,設定 ParameterFormatter 為 所需的值 XMLReturnReader
。
[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::HttpGetClientProtocol
{
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::UrlParameterWriter::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.HttpGetClientProtocol
{
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.UrlParameterWriter))]
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.HttpGetClientProtocol
Public Sub New()
Me.Url = "http://www.contoso.com/username.asmx"
End Sub
<HttpMethodAttribute(GetType(XmlReturnReader), GetType(UrlParameterWriter))> _
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 或 HTTP-POST 叫用 XML Web 服務方法, ParameterFormatter 必須是 XMLReturnReader
。