如何将Web服务XML输出存储到字符串变量中 [英] how to store webservice XML output into string variable

查看:148
本文介绍了如何将Web服务XML输出存储到字符串变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我将一个Web服务设为"myweb",并将对该Web服务的引用添加到C#Web应用程序中.项目.我将Web服务方法validate("5","62")调用到Web应用程序中.

hi Everyone,

I make one webservice "myweb" and add reference to this webservice to C# web application. project. I call the web service method validate("5","62") in to web application.

ReconServiceService objReconServiceService = new ReconServiceService();
  String s = objReconServiceService.validate("5", "62")



但是我遇到了错误,因为网络服务将输出返回为XML格式,并且无法直接存储到任何变量.
我想知道任何将XML输出转换并将结果打印到c#Web应用程序的任何变量中的功能.

在此先感谢
问候,
Ravi.



But i got error,because webservice return the output into XML format and cannot store directly to any variable.
I want to know any functionality that cast the XML output and print the result in to any variable of c# web application.

Thanks in advance
Regards,
Ravi.

推荐答案

为什么要更改函数的返回值?为什么不存储返回的内容?如果要取回Xml文档,则可以使用它的属性来访问基础XML,但是将XML存储在字符串中会大大降低XML的有用性.改用正确的方法从XML中提取数据,除非您需要将XML逐字传递给执行此操作的对象.在这种情况下,请使用包含XML的类的属性(有多个属性,因此我们需要知道哪个属性,但是您可以按一下.intellisense会向您显示选项).
Why would you want to change the return value of a function ? Why not store what is being returned ? If you are getting an Xml document back, you can use it''s properties to access the underlying XML, but the usefulness of XML is greatly diminished by storing it in a string. Use the right methods to extract the data from your XML instead, unless what you need is to pass the XML verbatim to something that does that. In which case, use the properties of the class containing the XML ( there''s more than one, so we''d need to know which one, but you can hit the . and intellisense will show you your options ).


这篇关于如何将Web服务XML输出存储到字符串变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆