我的客户端需要将Url传递给我的WSDL Web服务。他们使用SoapHttpClientProtocol Url属性来设置它的值。例如我的客户通过URL值,这是“http://www.contoso.com/math.asmx”:如何从Web服务使用者访问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我的Web方法中的价值。 Web服务例子:
<%@ 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;
}
}
我如何可以访问我的客户在我的web服务方法设置这些SoapHttpClientProtocol Url属性值?
任何人请咨询。
这是什么样的网络服务? ASMX? WCF? – 2010-07-03 00:39:31
Web服务是ASMX。 – jeff 2010-07-03 04:38:37