webservice and IXMLSerializable

  • Thread starter Frederik Vanderhaegen
  • Start date
F

Frederik Vanderhaegen

Hi,

I'm writing a webservice who returns a custom objects, which implement the
IXMLSerializable interface.
When I'm testing the de/serialization (using the xmlSerializer class) of
the custom class with a windows form application everything works perfect,
so I can say the classes are de/serialized like it should be.
But when I'm implement it in a webservice I get some problems.
First the sample code (simplified):
//DTO
public class myDTO:IXmlSerializable
{
private string _UserName;
public myDTO(string UserName)
{
_UserName=UserName;
}
public void WriteXml(System.Xml.XmlWriter writer)
{
//write the xml
}

public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}

public void ReadXml(System.Xml.XmlReader reader)
{
//read the xml
}
}
//WebService
[WebService(Namespace="http://xxx.yy/webservices/")]
public class MyWebService : System.Web.Services.WebService
{
[WebMethod()]
public myDTO TestFunction(string userName)
{
return new myDTO(userName);
}
}
//Client Proxy (had to change System.Data.DataSet by object)
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://xxx.yy/webservices/TestFunction",
RequestNamespace="http://xxx.yy/webservices/",
ResponseNamespace="http://xxx.yy/webservices/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public object TestFunction(string userName) {
object[] results = this.Invoke("TestFunction", new object[] {
userName});
return results[0];
}

When I execute following test code, test.GetType().FullName returns an array
of xmlnodes in stead of myDTO:

localhost.MyWebService myservice = new localhost.MyWebService();
object test = myservice.TestFunction("test");

Does anyone know what I'm doing wrong?
I suppose it has something to do with my webservice because without the use
of that everything works like it should be.

Thx in advance.

Frederik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top