Share via


SoapHttpClientProtocol クラス

定義

SOAP 使用時のクライアント プロキシの派生元となるクラスを指定します。

public ref class SoapHttpClientProtocol : System::Web::Services::Protocols::HttpWebClientProtocol
public class SoapHttpClientProtocol : System.Web.Services.Protocols.HttpWebClientProtocol
[System.Runtime.InteropServices.ComVisible(true)]
public class SoapHttpClientProtocol : System.Web.Services.Protocols.HttpWebClientProtocol
type SoapHttpClientProtocol = class
    inherit HttpWebClientProtocol
[<System.Runtime.InteropServices.ComVisible(true)>]
type SoapHttpClientProtocol = class
    inherit HttpWebClientProtocol
Public Class SoapHttpClientProtocol
Inherits HttpWebClientProtocol
継承
属性

次のコード例は、XML Web サービスの Math Wsdl.exeによって生成されるプロキシ クラスです。 プロキシ クラスの派生元 SoapHttpClientProtocolは、抽象 WebClientProtocol クラスから派生します。

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

namespace MyMath
{

   [System::Web::Services::WebServiceBindingAttribute(Name="MyMathSoap",Namespace="http://www.contoso.com/")]
   public ref class MyMath: public System::Web::Services::Protocols::SoapHttpClientProtocol
   {
   public:

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


      [System::Diagnostics::DebuggerStepThroughAttribute]
      [System::Web::Services::Protocols::SoapDocumentMethodAttribute("http://www.contoso.com/Add",
      RequestNamespace="http://www.contoso.com/",ResponseNamespace="http://www.contoso.com/",
      Use=System::Web::Services::Description::SoapBindingUse::Literal,
      ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)]
      int Add( int num1, int num2 )
      {
         array<Object^>^temp0 = {num1,num2};
         array<Object^>^results = this->Invoke( "Add", temp0 );
         return  *dynamic_cast<int^>(results[ 0 ]);
      }


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


      [System::Diagnostics::DebuggerStepThroughAttribute]
      int EndAdd( System::IAsyncResult^ asyncResult )
      {
         array<Object^>^results = this->EndInvoke( asyncResult );
         return  *dynamic_cast<int^>(results[ 0 ]);
      }

   };

}


namespace MyMath {
    using System.Diagnostics;
    using System.Xml.Serialization;
    using System;
    using System.Web.Services.Protocols;
    using System.Web.Services;

    [System.Web.Services.WebServiceBindingAttribute(Name="MyMathSoap", Namespace="http://www.contoso.com/")]
    public class MyMath : System.Web.Services.Protocols.SoapHttpClientProtocol {

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

        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.contoso.com/Add", RequestNamespace="http://www.contoso.com/", ResponseNamespace="http://www.contoso.com/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public int Add(int num1, int num2) {
            object[] results = this.Invoke("Add", new object[] {num1,
                        num2});
            return ((int)(results[0]));
        }

        [System.Diagnostics.DebuggerStepThroughAttribute()]
        public System.IAsyncResult BeginAdd(int num1, int num2, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("Add", new object[] {num1,
                        num2}, callback, asyncState);
        }

        [System.Diagnostics.DebuggerStepThroughAttribute()]
        public int EndAdd(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((int)(results[0]));
        }
    }
}

Option Strict On
Option Explicit On

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

Namespace MyMath
    
    <System.Web.Services.WebServiceBindingAttribute(Name:="MyMathSoap", [Namespace]:="http://www.contoso.com/")>  _
    Public Class MyMath
        Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
        
        <System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Public Sub New()
            MyBase.New
            Me.Url = "http://www.contoso.com/math.asmx"
        End Sub
        
        <System.Diagnostics.DebuggerStepThroughAttribute(),  _
         System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.contoso.com/Add", RequestNamespace:="http://www.contoso.com/", ResponseNamespace:="http://www.contoso.com/", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>  _
        Public Function Add(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
            Dim results() As Object = Me.Invoke("Add", New Object() {num1, num2})
            Return CType(results(0),Integer)
        End Function
        
        <System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Public Function BeginAdd(ByVal num1 As Integer, ByVal num2 As Integer, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult
            Return Me.BeginInvoke("Add", New Object() {num1, num2}, callback, asyncState)
        End Function
        
        <System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Public Function EndAdd(ByVal asyncResult As System.IAsyncResult) As Integer
            Dim results() As Object = Me.EndInvoke(asyncResult)
            Return CType(results(0),Integer)
        End Function
    End Class
End Namespace

次のコード例は、上記の Math プロキシ クラスが生成された XML Web サービスです。

重要

この例には、ユーザー入力を受け付けるテキスト ボックスがあります。これにより、セキュリティが脆弱になる可能性があります。 既定では、ASP.NET Web ページによって、ユーザー入力にスクリプトまたは HTML 要素が含まれていないかどうかが検証されます。 詳細については、「スクリプトによる攻略の概要」を参照してください。

<%@ WebService Language="C#" Class="MyMath"%>
 using System.Web.Services;
 using System;
 
 [WebService(Namespace="http://www.contoso.com/")] 
 public class MyMath {
    
    [ WebMethod ]
    public int Add(int num1, int num2) {
        return num1+num2;
    }
 }
<%@ WebService Language="VB" Class="MyMath"%>
Imports System.Web.Services
Imports System

<WebService(Namespace:="http://www.contoso.com/")> _
Public Class MyMath
    <WebMethod()> _
    Public Function Add(num1 As Integer, num2 As Integer) As Integer
        Return num1 + num2
    End Function 'Add
End Class 'Math

注釈

XML Web サービス クライアントを構築する場合は、間接的または直接派生 WebClientProtocol するプロキシ クラスを XML Web サービス用に作成する必要があります。 SOAP を使用して XML Web サービス クライアントを呼び出す場合は、プロキシ クラスから SoapHttpClientProtocol派生する必要があります。そこから派生します HttpWebClientProtocolHttpWebClientProtocol、順番に、から WebClientProtocol派生します。

XML Web サービスと通信するには、呼び出す XML Web サービスに対して間接的または直接 WebClientProtocol 派生するプロキシ クラスを作成します。 プロキシ クラスを手動で作成する代わりに、Web サービス記述言語ツール (Wsdl.exe) を使用して、特定の XML Web サービスのサービス記述のプロキシ クラスを作成します。 SOAP プロトコルに対してプロキシ クラスが生成されると、XML Web サービス メソッドへの同期呼び出しがメソッドを介してInvoke行われますが、非同期呼び出しはメソッドとメソッドをBeginInvokeEndInvoke使用して行われます。

注意 (継承者)

このクラスをオーバーライドすると、特定の種類の XML Web サービスに固有の派生クラスにメソッドを導入できます。 メソッドはパラメーターをキャプチャし、基本クラスを呼び出して XML Web サービスとの通信を行います。 導入されたメソッドが非同期の場合は、メソッドとメソッドをBeginInvoke(String, Object[], AsyncCallback, Object)EndInvoke(IAsyncResult)呼び出します。 導入されたメソッドが同期型の場合は、メソッドを Invoke(String, Object[]) 呼び出します。 オーバーライドされたコンストラクターは、通常、プロパティを Url XML Web サービス メソッドの URL に設定します。

コンストラクター

SoapHttpClientProtocol()

SoapHttpClientProtocol クラスの新しいインスタンスを初期化します。

プロパティ

AllowAutoRedirect

クライアントがサーバーのリダイレクトに自動的に従うかどうかを取得または設定します。

(継承元 HttpWebClientProtocol)
CanRaiseEvents

コンポーネントがイベントを発生させることがきるかどうかを示す値を取得します。

(継承元 Component)
ClientCertificates

クライアント証明書のコレクションを取得します。

(継承元 HttpWebClientProtocol)
ConnectionGroupName

要求に対して使用する接続グループの名前を取得または設定します。

(継承元 WebClientProtocol)
Container

IContainer を含む Component を取得します。

(継承元 Component)
CookieContainer

クッキーのコレクションを取得または設定します。

(継承元 HttpWebClientProtocol)
Credentials

XML Web サービス クライアント認証のセキュリティ資格情報を取得または設定します。

(継承元 WebClientProtocol)
DesignMode

Component が現在デザイン モードかどうかを示す値を取得します。

(継承元 Component)
EnableDecompression

この HttpWebClientProtocol の圧縮解除が有効かどうかを示す値を取得または設定します。

(継承元 HttpWebClientProtocol)
Events

Component に結び付けられているイベント ハンドラーのリストを取得します。

(継承元 Component)
PreAuthenticate

事前認証を有効にするかどうかを取得または設定します。

(継承元 WebClientProtocol)
Proxy

ファイアウォールをとおして XML Web サービス要求を行うためのプロキシ情報を取得または設定します。

(継承元 HttpWebClientProtocol)
RequestEncoding

クライアントが XML Web サービスを要求するときに使用される Encoding

(継承元 WebClientProtocol)
Site

ComponentISite を取得または設定します。

(継承元 Component)
SoapVersion

XML Web サービスに対して SOAP 要求を行うために使用する SOAP プロトコルのバージョンを取得または設定します。

Timeout

同期的な XML Web サービスの要求に対する返答の受信を XML Web サービス クライアントが待機する時間 (ミリ秒単位) を示します。

(継承元 WebClientProtocol)
UnsafeAuthenticatedConnectionSharing

XML Web サービスをホストしている Web サービスに接続するときにクライアントが NTLM 認証を使用する場合、接続共有が有効になっているかどうかを示す値を取得または設定します。

(継承元 HttpWebClientProtocol)
Url

クライアントが要求している XML Web サービスのベース URL を取得または設定します。

(継承元 WebClientProtocol)
UseDefaultCredentials

Credentials プロパティを DefaultCredentials プロパティの値に設定するかどうかを示す値を取得または設定します。

(継承元 WebClientProtocol)
UserAgent

それぞれの要求と共に送信されるユーザー エージェント ヘッダーの値を取得または設定します。

(継承元 HttpWebClientProtocol)

メソッド

Abort()

XML Web サービス メソッドへの要求をキャンセルします。

(継承元 WebClientProtocol)
BeginInvoke(String, Object[], AsyncCallback, Object)

SOAP を使用して XML Web サービス メソッドの非同期呼び出しを開始します。

CancelAsync(Object)

呼び出しが完了済みの場合を除き、XML Web サービス メソッドの非同期呼び出しをキャンセルします。

(継承元 HttpWebClientProtocol)
CreateObjRef(Type)

リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。

(継承元 MarshalByRefObject)
Discover()

Url にある探索ドキュメントに記述されている XML Web サービスに動的にバインドします。

Dispose()

Component によって使用されているすべてのリソースを解放します。

(継承元 Component)
Dispose(Boolean)

Component によって使用されているアンマネージド リソースを解放し、オプションでマネージド リソースも解放します。

(継承元 Component)
EndInvoke(IAsyncResult)

SOAP を使用して XML Web サービス メソッドの非同期呼び出しを終了します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetLifetimeService()
互換性のために残されています。

対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
GetReaderForMessage(SoapClientMessage, Int32)

XmlReader パラメーターの Stream プロパティで初期化された SoapClientMessage を返します。

GetService(Type)

Component またはその Container で提供されるサービスを表すオブジェクトを返します。

(継承元 Component)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
GetWebRequest(Uri)

指定した uri に対して WebRequest を作成します。

GetWebResponse(WebRequest)

XML Web サービス メソッドへの同期要求から応答を返します。

(継承元 HttpWebClientProtocol)
GetWebResponse(WebRequest, IAsyncResult)

XML Web サービス メソッドへの非同期要求から応答を返します。

(継承元 HttpWebClientProtocol)
GetWriterForMessage(SoapClientMessage, Int32)

XmlWriter パラメーターの Stream プロパティで初期化された SoapClientMessage を返します。

InitializeLifetimeService()
互換性のために残されています。

このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
Invoke(String, Object[])

SOAP を使用して XML Web サービス メソッドを同期的に呼び出します。

InvokeAsync(String, Object[], SendOrPostCallback)

指定されたメソッドを非同期で呼び出します。

InvokeAsync(String, Object[], SendOrPostCallback, Object)

指定されたメソッドを非同期で呼び出します。

MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
MemberwiseClone(Boolean)

現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。

(継承元 MarshalByRefObject)
ToString()

Component の名前 (存在する場合) を格納する String を返します。 このメソッドはオーバーライドできません。

(継承元 Component)

events

Disposed

Dispose() メソッドの呼び出しによってコンポーネントが破棄されるときに発生します。

(継承元 Component)

適用対象

スレッド セーフ

この型はスレッド セーフです。

こちらもご覧ください