次の方法で共有


HttpMethodAttribute.ReturnFormatter プロパティ

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

Public Property ReturnFormatter As Type
[C#]
public Type ReturnFormatter {get; set;}
[C++]
public: __property Type* get_ReturnFormatter();public: __property void set_ReturnFormatter(Type*);
[JScript]
public function get ReturnFormatter() : Type;public function set ReturnFormatter(Type);

プロパティ値

XML Web サービス メソッドからの応答を逆シリアル化する Type 。既定値はありません。

解説

XML Web サービス クライアントが HTTP-GET を使用して XML Web サービス メソッドを呼び出している場合は、 ReturnFormatterUrlParameterWriter にする必要があります。一方、HTTP-POST を使用するクライアントでは、 ReturnFormatterHtmlFormParameterWriter に設定する必要があります。

使用例

HTTP-GET を使用する XML Web サービス クライアントに対して Wsdl.exe ユーティリティによって生成されるプロキシ クラスの例を次に示します。この場合、 ReturnFormatter は必須値 UrlParameterWriter に設定します。

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

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

End Class 'UserName

[C#] 
public class MyUser : System.Web.Services.Protocols.HttpGetClientProtocol {
    
    public MyUser() {
        this.Url = "https://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;
}


[C++] 
[System::Xml::Serialization::XmlRootAttribute(Namespace=S"http://tempuri.org/", IsNullable=true)]
public __gc class UserName {
    
public:
    String* Name;
    String* Domain;
};

public __gc class MyUser : public System::Web::Services::Protocols::HttpGetClientProtocol {
    
public:
    MyUser() {
        this->Url = S"https://www.contoso.com/username.asmx";
    }
    
    [System::Web::Services::Protocols::HttpMethodAttribute(__typeof(System::Web::Services::Protocols::XmlReturnReader), __typeof(System::Web::Services::Protocols::UrlParameterWriter))]
    UserName* GetUserName() {
        return (dynamic_cast<UserName*>(this->Invoke(S"GetUserName", (String::Concat( this->Url, S"/GetUserName" )), new Object*[0])));
    }
    
    System::IAsyncResult* BeginGetUserName(System::AsyncCallback* callback, Object* asyncState) {
        return this->BeginInvoke(S"GetUserName", (String::Concat( this->Url, S"/GetUserName" )), new Object*[0], callback, asyncState);
    }
    
    UserName* EndGetUserName(System::IAsyncResult* asyncResult) {
        return (dynamic_cast<UserName*>(this->EndInvoke(asyncResult)));
    }
};


[JScript] 
class MyUser extends System.Web.Services.Protocols.HttpGetClientProtocol{
    
    function MyUser(){
        this.Url = "https://www.contoso.com/username.asmx"
    } //New
    
    public HttpMethodAttribute(XmlReturnReader, UrlParameterWriter)
    function GetUserName() : UserName{
        return UserName(this.Invoke("GetUserName", this.Url + "/GetUserName", new Object[0]))
    } //GetUserName

    function BeginGetUserName(callback : System.AsyncCallback, asyncState : Object) : System.IAsyncResult{
        return this.BeginInvoke("GetUserName", this.Url + "/GetUserName", new Object[0], callback, asyncState)
    } //BeginGetUserName

    function EndGetUserName(asyncResult : System.IAsyncResult) : UserName{
        return UserName(this.EndInvoke(asyncResult))
    } //EndGetUserName
} //MyUser

public XmlRootAttribute(Namespace = "http://tempuri.org/", IsNullable = true)
class UserName{
    var Name : String
    var Domain : String
} //UserName

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

HttpMethodAttribute クラス | HttpMethodAttribute メンバ | System.Web.Services.Protocols 名前空間