I am trying to update some WCF service methods that return strings to return XmlDocument objects. I've tried returning it as-is and encapsulating it in a datacontract object. Either way I'm hitting an error upon attempting to update the service reference. The error suggest encapsulating it in a datacontract with an operations contract which I am doing. Is there a trick to this?
相关问题
- How to make a .svc file write to asp.net Trace.axd
- WCF Service Using Client Certificates Requires Ano
- WCF error with net.tcp "The service endpoint faile
- WCF Service Reference Support Files Not Updating
- WCF Web Service: Upload a file, Process that file,
相关文章
- WCF发布Windows服务 POST方式报错 GET方式没有问题 应该怎么解决?
- XCopy or MOVE do not work when a WCF Service runs
- Could not find default endpoint element that refer
- The 'DbProviderFactories' section can only
- Do I need to expose a constructor in a WCF DataCon
- exposing net.tcp endpoint
- When is destructor called in a WCF service
- Getting error detail from WCF REST
There's a way to return a XmlDocument from WCF, but you need to use the
XmlSerializer
instead of the default serializer (DataContractSerialier
) - the code below shows how it can be done. Having said that, do consider using data transfer objects as mentioned in the comments, unless your scenario really requires a XmlDocument to be transferred.If you want to be able to pass arbitrary XML on the wire the best way to do it is to use XElement rather than XmlDocument
XmlDocument isn't serializable