如何从WCF Web服务返回XML?

时间:2022-10-30 23:28:11

The web service in question must return results of a stored procedure in SOAP XML.

有问题的Web服务必须在SOAP XML中返回存储过程的结果。

I can return any object from a web service no problem, I'm even familiar with serializing JSON from an .asmx service but I'm totally stumped with the concept of returning XML from a web service who's job is to retrieve results from a stored procedure. It's very important to me this, so any help seriously appreciated.

我可以从Web服务返回任何对象没问题,我甚至熟悉从.asmx服务序列化JSON,但我完全不知道从Web服务返回XML的概念,其工作是从存储中检索结果程序。这对我来说非常重要,所以任何帮助都要认真对待。

Thankyou.

谢谢。

2 个解决方案

#1


1  

Try returning an XmlNode:

尝试返回XmlNode:

[ServiceContract]
public interface IMyService
{
    ...
    [OperationContract]
    XmlNode MyMethod(...);

    ...
}

#2


0  

Other than returning XML as a string you can look at WCF REST http://msdn.microsoft.com/en-us/netframework/dd547388 which can be added to give you VS project templates for XML/JSON WCF projects.

除了将XML作为字符串返回之外,您可以查看WCF REST http://msdn.microsoft.com/en-us/netframework/dd547388,可以添加它以为您提供XML / JSON WCF项目的VS项目模板。

#1


1  

Try returning an XmlNode:

尝试返回XmlNode:

[ServiceContract]
public interface IMyService
{
    ...
    [OperationContract]
    XmlNode MyMethod(...);

    ...
}

#2


0  

Other than returning XML as a string you can look at WCF REST http://msdn.microsoft.com/en-us/netframework/dd547388 which can be added to give you VS project templates for XML/JSON WCF projects.

除了将XML作为字符串返回之外,您可以查看WCF REST http://msdn.microsoft.com/en-us/netframework/dd547388,可以添加它以为您提供XML / JSON WCF项目的VS项目模板。