다음을 통해 공유


SoapHttpClientProtocol.Invoke(String, Object[]) 메서드

정의

SOAP를 사용하여 XML Web services 메서드를 동기적으로 호출합니다.

protected:
 cli::array <System::Object ^> ^ Invoke(System::String ^ methodName, cli::array <System::Object ^> ^ parameters);
protected:
 cli::array <System::Object ^> ^ Invoke(System::String ^ method_name, cli::array <System::Object ^> ^ parameters);
protected object[] Invoke (string methodName, object[] parameters);
protected object[] Invoke (string method_name, object[] parameters);
member this.Invoke : string * obj[] -> obj[]
member this.Invoke : string * obj[] -> obj[]
Protected Function Invoke (methodName As String, parameters As Object()) As Object()
Protected Function Invoke (method_name As String, parameters As Object()) As Object()

매개 변수

methodNamemethod_name
String

XML Web services 메서드의 이름입니다.

parameters
Object[]

XML 웹 서비스에 전달할 매개 변수가 들어 있는 개체의 배열입니다. 배열 내의 값 순서는 파생 클래스의 호출 메서드에 있는 매개 변수의 순서와 일치합니다.

반환

Object[]

파생 클래스 메서드의 반환 값과 reference 또는 out 매개 변수가 들어 있는 개체의 배열입니다.

예외

서버 컴퓨터에 요청이 도달했지만 성공적으로 처리되지 않은 경우

요청은 개체의 현재 상태에서 유효하지 않습니다.

네트워크에 액세스하는 동안 오류가 발생한 경우.

예제

다음 코드 예제는 XML 웹 서비스에 대 Math 한 Wsdl.exe 생성 된 프록시 클래스입니다. Add 프록시 클래스 Invoke 의 메서드 내에서 메서드는 XML 웹 서비스 메서드를 호출합니다Add.

#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

다음 코드 예제는 이전 프록시 클래스를 만든 XML 웹 서비스입니다 Math .

<%@ 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 웹 서비스에 대한 고유한 프록시 클래스를 Invoke 빌드하지 않는 한 메서드를 직접 호출하지 않습니다.

XML 웹 서비스에 대한 Wsdl.exe(Web Services Description Language) 도구에서 생성된 프록시 클래스는 XML 웹 서비스 메서드를 프록시 클래스의 이름으로 노출합니다. 프록시 클래스는 메서드를 Invoke 호출하여 XML 웹 서비스 메서드 호출을 호출합니다. 예를 들어 XML 웹 서비스가 명명 Add된 XML 웹 서비스 메서드를 노출하는 경우 프록시 클래스에는 이름이 지정된 Add메서드도 포함됩니다. 프록시 클래스의 Add 메서드에 대한 코드 내에서 메서드를 통해 Invoke XML 웹 서비스 메서드에 대한 동기 호출을 수행한 다음 결과는 예상되는 반환 형식 Add에 배치됩니다.

매개 methodName 변수는 메서드에 추가되었을 수 있는 사용자 지정 특성을 찾는 데 사용됩니다(예: SoapDocumentMethodAttribute.). SoapDocumentMethodAttribute 는 SOAP 프로토콜에 필요한 파생 메서드에 대한 추가 정보를 제공합니다.

적용 대상

추가 정보