简体   繁体   English

调用webservice方法时获取XML响应

[英]Get XML response when calling webservice method

Is it possible to get XML response parallel with calling webservice method; 是否有可能在调用webservice方法的同时获得XML响应;

For example: 例如:

var ws = new WebReference.WService();
String result = ws.HelloWorld();

I need to get XML response from webservice for HelloWorld() function like 我需要从Web服务获取HelloWorld()函数的XML响应,例如

<string xmlns="http://tempuri.org/">Hello World</string>

and parallel string result in variable result = "Hello World" 和并行字符串导致变量result = "Hello World"

In order to avoid calling the same method twice, you'll need to move to a WCF approach, implementing an IEndpointBehavior behavior to read the raw communication with your webservice endpoint. 为了避免两次调用相同的方法,您需要转到WCF方法,实现IEndpointBehavior行为以读取与IEndpointBehavior端点的原始通信。

An example for such behavior can be found at Generic WCF Host . 有关此类行为的示例,请参见“ 通用WCF主​​机”

This is answer https://stackoverflow.com/a/13779722/1179895 . 这是答案https://stackoverflow.com/a/13779722/1179895 But it is necessary to add service reference to project as a service, NOT web service. 但是有必要将服务引用添加到项目即服务而不是Web服务中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM