Freigeben über


HttpSimpleClientProtocol-Klasse

Stellt mithilfe der einfachen Bindungen des HTTP-GET-Protokolls und des HTTP-POST-Protokolls die Basisklasse für die Kommunikation mit einem XML-Webdienst dar.

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

Syntax

'Declaration
<ComVisibleAttribute(True)> _
Public MustInherit Class HttpSimpleClientProtocol
    Inherits HttpWebClientProtocol
'Usage
Dim instance As HttpSimpleClientProtocol
[ComVisibleAttribute(true)] 
public abstract class HttpSimpleClientProtocol : HttpWebClientProtocol
[ComVisibleAttribute(true)] 
public ref class HttpSimpleClientProtocol abstract : public HttpWebClientProtocol
/** @attribute ComVisibleAttribute(true) */ 
public abstract class HttpSimpleClientProtocol extends HttpWebClientProtocol
ComVisibleAttribute(true) 
public abstract class HttpSimpleClientProtocol extends HttpWebClientProtocol

Hinweise

Diese Klasse gibt den größten Teil der Implementierung für die Kommunikation mit einem XML-Webdienst über HTTP unter Verwendung von Encodern für die Codierung der Parameter und Rückgabewerte in gemeinsamen MIME-Formaten an. Diese Encoder werden von der MimeFormatter-Klasse abgeleitet. Standardmäßig codiert eine vom HttpSimpleClientProtocol abgeleitete Proxyklasse Parameter unter Verwendung des MIME-Typs "application/x-www-form-urlencoded" und die Antwort in reinem XML. Benutzerdefinierte MIME-Formatierungsprogramme können mithilfe des HttpMethodAttribute-Attributs angegeben werden. Das Integrieren dieser Möglichkeit in eine Dienstbeschreibung und Proxygenerierung wird jedoch nicht unterstützt.

Notes to Inheritors: Wenn Sie diese Klasse überschreiben, können Sie für einen bestimmten XML-Webdiensttyp spezifische Methoden in die abgeleitete Klasse einfügen. Diese Methoden zeichnen lediglich die Parameter auf und rufen die Basisklasse für die Kommunikation mit der Site auf. Wenn die eingefügten Methoden asynchron sind, rufen Sie die BeginInvoke-Methode und die EndInvoke-Methode auf. Wenn die eingefügten Methoden synchron sind, rufen Sie die Invoke-Methode auf. Der überschriebene Konstruktor legt die Url-Eigenschaft i. d. R. auf den URI der XML-Webdienstmethode fest.

Das WSDL-Tool (Web Services Description Language) mit dem Namen Wsdl.exe generiert abgeleitete Klassen von HttpSimpleClientProtocol für eine angegebene Dienstbeschreibung.

Beispiel

Im folgenden Codebeispiel wird eine von Wsdl.exe generierte Proxyklasse für den unten aufgeführten Math-XML-Webdienst veranschaulicht. Die Proxyklasse wird vom HttpGetClientProtocol abgeleitet, das wiederum von der abstrakten HttpSimpleClientProtocol-Klasse abgeleitet wird.

Option Strict On
Option Explicit On

Imports System
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization


Public Class MyMath
    Inherits System.Web.Services.Protocols.HttpGetClientProtocol
    
    <System.Diagnostics.DebuggerStepThroughAttribute()>  _
    Public Sub New()
        MyBase.New
        Me.Url = "https://www.contoso.com/math.asmx"
    End Sub
    
    <System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.Web.Services.Protocols.HttpMethodAttribute(GetType(System.Web.Services.Protocols.XmlReturnReader), GetType(System.Web.Services.Protocols.UrlParameterWriter))>  _
    Public Function Add(ByVal num1 As String, ByVal num2 As String) As <System.Xml.Serialization.XmlRootAttribute("int", [Namespace]:="https://www.contoso.com/", IsNullable:=false)> Integer
        Return CType(Me.Invoke("Add", (Me.Url + "/Add"), New Object() {num1, num2}),Integer)
    End Function
    
    <System.Diagnostics.DebuggerStepThroughAttribute()>  _
    Public Function BeginAdd(ByVal num1 As String, ByVal num2 As String, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult
        Return Me.BeginInvoke("Add", (Me.Url + "/Add"), New Object() {num1, num2}, callback, asyncState)
    End Function
    
    <System.Diagnostics.DebuggerStepThroughAttribute()>  _
    Public Function EndAdd(ByVal asyncResult As System.IAsyncResult) As Integer
        Return CType(Me.EndInvoke(asyncResult),Integer)
    End Function
End Class
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.Web.Services;


public class MyMath : System.Web.Services.Protocols.HttpGetClientProtocol {
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    public MyMath() {
        this.Url = "https://www.contoso.com/math.asmx";
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Web.Services.Protocols.HttpMethodAttribute(typeof(System.Web.Services.Protocols.XmlReturnReader), typeof(System.Web.Services.Protocols.UrlParameterWriter))]
    [return: System.Xml.Serialization.XmlRootAttribute("int", Namespace="https://www.contoso.com/", IsNullable=false)]
    public int Add(string num1, string num2) {
        return ((int)(this.Invoke("Add", (this.Url + "/Add"), new object[] {num1,
                    num2})));
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    public System.IAsyncResult BeginAdd(string num1, string num2, System.AsyncCallback callback, object asyncState) {
        return this.BeginInvoke("Add", (this.Url + "/Add"), new object[] {num1,
                    num2}, callback, asyncState);
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    public int EndAdd(System.IAsyncResult asyncResult) {
        return ((int)(this.EndInvoke(asyncResult)));
    }
}
#using <System.Web.Services.dll>
#using <System.Xml.dll>
#using <System.dll>

using namespace System::Diagnostics;
using namespace System::Xml::Serialization;
using namespace System;
using namespace System::Web::Services::Protocols;
using namespace System::Web::Services;

public ref class MyMath: public System::Web::Services::Protocols::HttpGetClientProtocol
{
public:

   [System::Diagnostics::DebuggerStepThroughAttribute]
   MyMath()
   {
      this->Url = "https://www.contoso.com/math.asmx";
   }

   [System::Diagnostics::DebuggerStepThroughAttribute]
   [System::Web::Services::Protocols::HttpMethodAttribute(System::Web::Services::Protocols::XmlReturnReader::typeid,
   System::Web::Services::Protocols::UrlParameterWriter::typeid)]
   [returnvalue:System::Xml::Serialization::XmlRootAttribute("snippet1>",Namespace="https://www.contoso.com/",IsNullable=false)]
   int Add( String^ num1, String^ num2 )
   {
      array<Object^>^temp0 = {num1,num2};
      return  *dynamic_cast<int^>(this->Invoke( "Add", (String::Concat( this->Url, "/Add" )), temp0 ));
   }

   [System::Diagnostics::DebuggerStepThroughAttribute]
   System::IAsyncResult^ BeginAdd( String^ num1, String^ num2, System::AsyncCallback^ callback, Object^ asyncState )
   {
      array<Object^>^temp1 = {num1,num2};
      return this->BeginInvoke( "Add", (String::Concat( this->Url, "/Add" )), temp1, callback, asyncState );
   }

   [System::Diagnostics::DebuggerStepThroughAttribute]
   int EndAdd( System::IAsyncResult^ asyncResult )
   {
      return  *dynamic_cast<int^>(this->EndInvoke( asyncResult ));
   }
};
import System.Diagnostics.*;
import System.Xml.Serialization.*;
import System.*;
import System.Web.Services.Protocols.*;
import System.Web.Services.*;

public class MyMath extends System.Web.Services.Protocols.HttpGetClientProtocol
{   
    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */
    public MyMath()
    {
        this.set_Url("https://www.contoso.com/math.asmx");
    } //MyMath
   
    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */
    /** @attribute System.Web.Services.Protocols.HttpMethodAttribute
        (System.Web.Services.Protocols.XmlReturnReader.class,
        System.Web.Services.Protocols.UrlParameterWriter.class)
     */
    public int Add(String num1, String num2)
    {
        return Integer.parseInt(System.Convert.ToString( 
            this.Invoke("Add", this.get_Url() + "/Add", 
            new Object[]{num1, num2})));
    } //Add  
   
    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */
    public System.IAsyncResult BeginAdd(String num1, String num2, 
        System.AsyncCallback callback, Object asyncState)
    {
        return this.BeginInvoke("Add", this.get_Url() + "/Add", 
            new Object[]{num1, num2}, callback, asyncState) ;
    } //BeginAdd   
   
    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */
    public int EndAdd(System.IAsyncResult asyncResult)
    {
        return Integer.parseInt(System.Convert.ToString(
            this.EndInvoke(asyncResult))) ;
    } //EndAdd
} //MyMath

Im folgenden Codebeispiel wird der Math-XML-Webdienst veranschaulicht, aus dem die vorherige Proxyklasse erstellt wurde.

Imports System.Web.Services
Imports System

Public Class Math
    <WebMethod()> _
    Public Function Add(num1 As Integer, num2 As Integer)As Integer
    
        Return num1 + num2
    End Function
    
End Class
using System.Web.Services;
using System;

public class Math {
     [ WebMethod ]
     public int Add(int num1, int num2) {
         return num1+num2;
         }
}
#using <System.EnterpriseServices.dll>
#using <System.Web.Services.dll>

using namespace System::Web::Services;
using namespace System;
public ref class Math
{
public:

   [WebMethod]
   int Add( int num1, int num2 )
   {
      return num1 + num2;
   }

};
import System.Web.Services
import System

class Math{
    public WebMethod()
    function Add(num1 : int, num2 : int): int{
        return num1 + num2
    }   
}

Vererbungshierarchie

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Web.Services.Protocols.WebClientProtocol
         System.Web.Services.Protocols.HttpWebClientProtocol
          System.Web.Services.Protocols.HttpSimpleClientProtocol
             System.Web.Services.Protocols.HttpGetClientProtocol
             System.Web.Services.Protocols.HttpPostClientProtocol

Threadsicherheit

Dieser Typ ist für Multithreadoperationen sicher.

Plattformen

Windows 98, Windows 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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

HttpSimpleClientProtocol-Member
System.Web.Services.Protocols-Namespace
SoapHttpClientProtocol