如何在客户端应用程序
问题描述:
我箱使用C#。对于使用本文如何在客户端应用程序
http://highcoding.blogspot.in/
中指定的DLL加密的响应,一个web服务WebMetod
[WebMethod]
[EncryptionExtension(Decrypt = DecryptMode.None, Encrypt = EncryptMode.Response, Target = Target.Body)]
[TracingExtension(TracingMode = TracingMode.Response, MethodName = "HelloWorld")]
public string HelloWorld() {
return "Hello World";
}
使用SOAP扩展我创建了一个Web服务客户端使用c#windows应用程序。
ServiceReference1.ServiceSoapClient ob = new WindowsFormsApplication2.ServiceReference1.ServiceSoapClient();
string st = ob.HelloWorld();
在这里,我得到一个错误“从命名空间‘http://schemas.xmlsoap.org/soap/envelope/’结束元素‘身体’预期”
加密是working.But我想和不能找到解决客户端数据的方法。任何人都知道如何在客户端处理这个问题?
答
在代理客户端代码中,“EncryptionExtension”属性添加到HelloWorld的方法
[EncryptionExtension(Decrypt = DecryptMode.Response, Encrypt = EncryptMode.None, Target = Target.Body)]
public string HelloWorld()
{
object[] results = this.Invoke("HelloWorld", new object[] { });
return ((string)(results[0]));
}
注意,这些代理是自动生成的代码。每次您对Web服务进行更改时,都会重新生成并且您的更改将会丢失。
处理这种情况的最佳方法是通过配置进行配置soap扩展。请点击此链接了解如何操作。
http://fluentbytes.com/applying-soap-extension-client-proxy-without-altering-generated-proxy-code/
Hai Raj ..我会试试这个。 – user922834 2012-04-16 14:25:14
我在哪里需要把这个代码..我试图通过在reference.cs文件中添加..它不工作 – user922834 2012-04-16 14:33:37
在哪里定义这个“调用”方法? – user922834 2012-04-16 14:36:19