HttpMethodAttribute.ReturnFormatter 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个 Type,它对来自 XML Web services 方法的响应进行反序列化。
public:
property Type ^ ReturnFormatter { Type ^ get(); void set(Type ^ value); };
public Type ReturnFormatter { get; set; }
member this.ReturnFormatter : Type with get, set
Public Property ReturnFormatter As Type
属性值
一个 Type,它对来自 XML Web services 方法的响应进行反序列化。 没有默认值。
示例
该示例是由使用 HTTP-GET 的 XML Web 服务客户端的 Wsdl.exe 实用工具生成的代理类,设置为 ReturnFormatter 所需的值 UrlParameterWriter
。
[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 调用 XML Web 服务方法, ReturnFormatter 则必须是 UrlParameterWriter
,而使用 HTTP-POST 的客户端必须设置为 ReturnFormatter HtmlFormParameterWriter
。