views:

29

answers:

1

My client is required to pass the Url to my WSDL web service. They use the SoapHttpClientProtocol Url property to set it's value. Example my client pass the url value which is "http://www.contoso.com/math.asmx":

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

However, I need to check the value that were pass to soapClient.Url inside my web method. Example web service:

<%@ 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;
          }
 }

How can i access these SoapHttpClientProtocol Url property value set by my clients in my web service method?

Any one please advice.

A: 

The properties of the SoapHttpClientProtocol object are used in order to create the connection from the client to your service. These properties include the URL, the network credentials, and other connection-related information.

None of this is sent to the service. It is only used.

Now, I don't know why you need this information. If you really need it, then you should perhaps send it in a SOAP Header, and make it part of the contract of the service.

Alternatively, you could use WCF. It implements WS-Addressing, which passes this information in the SOAP Envelope.

John Saunders
I will probably change my approach in the logic. Thanks for the answer.
jeff