This documentation is archived and is not being maintained.

HttpMethodAttribute Class

Applying this attribute to an XML Web service client using HTTP-GET or HTTP-POST, sets the types that serialize the parameters sent to an XML Web service method and read the response from the XML Web service method. This class cannot be inherited.

For a list of all members of this type, see HttpMethodAttribute Members.


[Visual Basic]
NotInheritable Public Class HttpMethodAttribute
   Inherits Attribute
public sealed class HttpMethodAttribute : Attribute
public __gc __sealed class HttpMethodAttribute : public Attribute
class HttpMethodAttribute extends Attribute

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


If an XML Web service client calls an XML Web service method using HTTP-GET, ReturnFormatter must be set to XmlReturnReader and ParameterFormatter set to UrlParameterWriter. XML Web service clients invoking a XML Web service using HTTP-POST must set ReturnFormatter to XmlReturnReader and ParameterFormatter to HtmlFormParameterWriter.


The following example is a proxy class generated by the Wsdl.exe utility for calling an XML Web service utility using HTTP-POST. The Wsdl.exe automatically supplies the correct types for ReturnFormatter and ParameterFormatter, along with specifying that the proxy class inherits from HttpPostClientProtocol.

[Visual Basic] 
Public Class MyUser
    Inherits System.Web.Services.Protocols.HttpPostClientProtocol
    Public Sub New()
        Me.Url = ""
    End Sub 'New
    <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 'MyUser

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

End Class 'UserName

public class MyUser : System.Web.Services.Protocols.HttpPostClientProtocol {
    public MyUser() {
        this.Url = "";
    [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="", IsNullable=true)]
public class UserName {
    public string Name;
    public string Domain;

[System::Xml::Serialization::XmlRootAttribute(Namespace=S"", IsNullable=true)]
public __gc class UserName {
    String* Name;
    String* Domain;
public __gc class MyUser : public System::Web::Services::Protocols::HttpPostClientProtocol {
    MyUser() {
        this->Url = S"";
    [System::Web::Services::Protocols::HttpMethodAttribute(__typeof(System::Web::Services::Protocols::XmlReturnReader), __typeof(System::Web::Services::Protocols::HtmlFormParameterWriter))]
    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)));

class MyUser extends System.Web.Services.Protocols.HttpPostClientProtocol{

    function MyUser(){
        this.Url = ""
    } //New

    public HttpMethodAttribute(XmlReturnReader, HtmlFormParameterWriter)
    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 = "", IsNullable = true)
class UserName{
    var Name : String
    var Domain : String

} //UserName


Namespace: System.Web.Services.Protocols

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Web.Services (in System.Web.Services.dll)

See Also

HttpMethodAttribute Members | System.Web.Services.Protocols Namespace | SoapDocumentMethodAttribute | SoapRpcMethodAttribute