【发布时间】:2010-01-31 11:00:06
【问题描述】:
我尝试在客户端设置soap扩展属性。例如:
在网络服务中的实现:
[AttributeUsage(AttributeTargets.Method)]
public class EncryptMessageAttribute : SoapExtensionAttribute
{
private string strKey="null";
public string StrKey
{
get { return strKey; }
set { strKey = value; }
}
}
Soap 扩展类:
public class EncryptMessage : SoapExtension
{
...
}
用于网络方法:
[WebMethod]
[EncryptMessage( StrKey = "pass")]
public string test2()
{
return "ok";
}
Proxy 类中的实现:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/test", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[EncryptMessage( StrKey = "pass")]
public string test() {
object[] results = this.Invoke("test", new object[0]);
return ((string)(results[0]));
}
Soap 扩展属性是::[EncryptMessage( StrKey = "pass")]
我想在客户端设置 Soap Extension 属性,在我使用 Soap Extension 之前,当我调用一些 web 方法时。
示例:我调用了一些方法,在使用soap 扩展之前,在两边都设置了soap 扩展属性。有人可以帮我吗?
【问题讨论】:
标签: c# asmx soap-extension