Reputation: 39
I created WCF Services. I have two files:
IHelloService.cs file:
namespace HelloService
{
[ServiceContract]
public interface IHelloService
{
[OperationContract]
void GetXmlDocumentt(XmlDocument Doc);
}
}
HelloService.cs file:
public void GetXmlDocumentt(XmlDocument Doc)
{
// return Doc;
}
I chose "Add Service Reference" and add my service reference and type in my client application:
XmlDocument xmlDoc = new XmlDocument();
//.. load xml from file
HelloService.HelloServiceClient client = new HelloService.HelloServiceClient("BasicHttpBinding_IHelloService");
client.GetXmlDocumentt(xmlDoc); // I get error in this line
I don't know why? because when I repleace type from XmlDocument to string in interface and I will pass client.GetXmlDocumentt("any data")
string in this line, everything works good.
Can you explain me why string type works but XmlDocument
don't work?
How can I change the code to XmlDocument
work good?
Thanks
Upvotes: 0
Views: 1785
Reputation: 758
XmlDocument
doesn't implement IXmlSerializable
interface, which is used by DataContractSerializer. You have 3 ways:
Xml.Linq
to deal with xml and send your data in XDocument
class.Upvotes: 2