Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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.

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in system.web.services.dll)

'Declaration
<AttributeUsageAttribute(AttributeTargets.Method)> _
Public NotInheritable Class HttpMethodAttribute
	Inherits Attribute
'Usage
Dim instance As HttpMethodAttribute

/** @attribute AttributeUsageAttribute(AttributeTargets.Method) */ 
public final class HttpMethodAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Method) 
public final class HttpMethodAttribute extends Attribute
Not applicable.

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.

Public Class MyUser
    Inherits System.Web.Services.Protocols.HttpPostClientProtocol
    
    
    Public Sub New()
        Me.Url = "http://www.contoso.com/username.asmx"
    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 := "http://tempuri.org/", IsNullable := True)> _
Public Class UserName
    Public Name As String
    Public Domain As String

End Class 'UserName

public class MyUser extends System.Web.Services.Protocols.HttpPostClientProtocol
{
    public MyUser()
    {
        this.set_Url("http://www.contoso.com/username.asmx");
    } //MyUser

    /** @attribute System.Web.Services.Protocols.HttpMethodAttribute
        (System.Web.Services.Protocols.XmlReturnReader .class,
        System.Web.Services.Protocols.HtmlFormParameterWriter .class)
     */
    public UserName GetUserName()
    {
        return ((UserName)(this.Invoke("GetUserName", this.get_Url()
            + "/GetUserName", new Object[0])));
    } //GetUserName

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

    public UserName EndGetUserName(System.IAsyncResult asyncResult)
    {
        return ((UserName)(this.EndInvoke(asyncResult)));
    } //EndGetUserName
} //MyUser

/** @attribute System.Xml.Serialization.XmlRootAttribute
    (Namespace = "http://tempuri.org/", IsNullable = true)
 */
public class UserName
{
    public String name;
    public String domain;
} //UserName

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

    function MyUser(){
        this.Url = "http://www.contoso.com/username.asmx"
    } //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 = "http://tempuri.org/", IsNullable = true)
class UserName{
    var Name : String
    var Domain : String

} //UserName

System.Object
   System.Attribute
    System.Web.Services.Protocols.HttpMethodAttribute

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

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft