2010-07-01 9 views
0

내 클라이언트가 URL을 WSDL 웹 서비스에 전달해야합니다. 그들은 SoapHttpClientProtocol Url 속성을 사용하여 값을 설정합니다.웹 서비스 사용자로부터 url 속성에 액세스하는 방법

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])); 
     } 
    } 
} 

그러나, 나는 내 웹 메서드 내 soapClient.Url에 패스를했다 값을 확인해야합니다 예 내 클라이언트는 "http://www.contoso.com/math.asmx을"되는 URL 값을 전달합니다. 예 웹 서비스 :

<%@ 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) { 
      //need to place logic to check the url pass by clients. 
      //if (url) place a logic here 
      //how do i check the SoapHttpClientProtocol url property? 

      return num1+num2; 
      } 
} 
난 내 웹 서비스 메서드에 내 고객에 의해 설정이 SoapHttpClientProtocol URL 속성 값에 액세스 할 수있는 방법을

?

아무쪼록 조언을 구하십시오.

+0

어떤 종류의 웹 서비스입니까? ASMX? WCF? –

+0

웹 서비스는 ASMX입니다. – jeff

답변

0

SoapHttpClientProtocol 개체의 속성은 클라이언트에서 서비스로의 연결을 만들기 위해 사용됩니다. 이러한 속성에는 URL, 네트워크 자격 증명 및 기타 연결 관련 정보가 포함됩니다.

이 내용은 서비스에 보내지 않았습니다. 오직 에 사용되었습니다.

이제 왜이 정보가 필요한지 알 수 없습니다. 정말 필요하다면 아마도 SOAP Header에 그것을 보내고 서비스 계약의 일부로 만들어야합니다.

또는 WCF를 사용할 수 있습니다. SOAP Envelope에이 정보를 전달하는 WS-Addressing을 구현합니다.

+0

아마도 로직에 대한 접근 방식을 바꿀 것입니다. 답변 해주셔서 감사합니다. – jeff

관련 문제