我得到一个web服务响应,如下所示。它在响应中有额外的XML标记和字符串标记。我无法将此响应加载到Dot中的XMLDocument对象中。我已经要求web服务提供商在发送响应之前删除这些标记。但他们说这是web服务标准。这是web服务发送响应的方式吗?
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/"><?xml version="1.0" encoding="UTF-8"?><?ACORD version="1.7.0"?>
<ACORD><InsuranceSvcRs></InsuranceSvcRs></ACORD></string>下面是调用web服务的代码
using (var webClient = new WebClient())
{
webClient.Credentials = Credentials;
byte[] responseArray;
NameValueCollection postValues = GetParameters();
responseArray = webClient.UploadValues(GetUploadURL(), "POST", postValues);
responseString = Encoding.ASCII.GetString(responseArray);
}由于我使用的是WebClient (而不是web服务代理),web客户端类是否会像这样格式化响应?
编辑:当我使用上面的代码尝试示例HelloWorld webservice时,得到的响应如下
<?xml version=\"1.0\" encoding=\"utf-8\"?><string xmlns=\"http://tempuri.org/\">Hello World</string>话虽如此,我还是要重新定义我的问题:当客户端代理发布到when服务时,webservice假设如何发送响应?
发布于 2010-07-10 00:01:18
他们说这是web服务标准
我所能推荐的就是更换服务提供商:-)
否则,除非您的服务提供商没有提供能够解析此标准的API,否则等待您的将是漫长而痛苦的字符串操作。
发布于 2010-07-10 00:10:26
重复的<?xml version="1.0" encoding="UTF-8"?>
如果服务给了你答案,那他们肯定有个bug。
发布于 2010-07-10 04:01:14
嘿,伙计们,谢谢你们的回复。因为我使用WebClient类来发布到他的webservice,所以响应内容确实包含"String“标签。但是如果我使用web服务代理,.net会为我们提取内容并删除字符串标记。因此,响应是web服务标准。当我使用示例服务进行测试时,得到的响应如下
<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<string xmlns=\"http://tempuri.org/\">Hello World</string>
https://stackoverflow.com/questions/3214384
复制相似问题