webservice and IXMLSerializable

Discussion in 'ASP .Net Web Services' started by Frederik Vanderhaegen, Oct 31, 2006.

  1. 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
     
    Frederik Vanderhaegen, Oct 31, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Ym9iYnk=?=

    IXmlSerializable

    =?Utf-8?B?Ym9iYnk=?=, Sep 28, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    481
    Teemu Keiski
    Sep 29, 2007
  2. Thomas D.

    IXmlSerializable: return type & difference IE / webservice

    Thomas D., Sep 1, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    222
    Thomas D.
    Sep 1, 2005
  3. Replies:
    0
    Views:
    315
  4. Jeremy
    Replies:
    3
    Views:
    343
    John Saunders [MVP]
    Jul 19, 2007
  5. DAXU

    web service and ixmlserializable

    DAXU, Dec 23, 2008, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    941
Loading...

Share This Page