Прочетете на английски Редактиране

Споделяне чрез


HttpMethodAttribute.ParameterFormatter Property

Definition

Gets or sets a Type that serializes parameters sent from an XML Web service client to the XML Web service method.

C#
public Type ParameterFormatter { get; set; }

Property Value

A Type that serializes parameters sent from an XML Web service client to an XML Web service method. There is no default.

Examples

The example is a proxy class generated by the Wsdl.exe utility for an XML Web service client using HTTP-GET, setting ParameterFormatter to the required value of XMLReturnReader.

C#
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;
}

Remarks

If the XML Web service client is invoking an XML Web service method using HTTP-GET or HTTP-POST, ParameterFormatter must be XMLReturnReader.

Applies to

Продукт Версии
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1