Typed DataSet serialization over Web Service

Discussion in 'ASP .Net Web Services' started by Adrian, Oct 27, 2003.

  1. Adrian

    Adrian Guest

    Hello everyone.

    I have the following problem:
    I want to pass a typed data set parameter to a Web Service method
    using the base class (DataSet) type in the parameter declaration. In
    the Web Service method I would like to cast this parameter to its
    original type but cast operation fails with an exception of type
    InvalidCastException. When I checked the type of the parameter in the
    WS method it doesn't show the original type but only the base class
    type (DataSet). Why the original type is not serialized in the Web
    Service call?

    Here is a bit of code to see what am I talking about.

    public class WS1 : WebService
    {
    [WebMethod]
    public void MethodA(DataSet ds)
    {
    DSMyType dsX = (DSMyType) ds; // InvalidCastException
    }
    }

    Proxy:
    public class WS1 : System.Web.Services.Protocols.SoapHttpClientProtocol
    {
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/MethodA",
    RequestNamespace="http://tempuri.org/",
    ResponseNamespace="http://tempuri.org/",
    Use=System.Web.Services.Description.SoapBindingUse.Literal,
    ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public void MethodA(DataSet ds)
    {
    object[] results = this.Invoke("MethodA ", new object[] {ds});
    }
    }

    Client:
    public void MethodB()
    {
    DSMyType dsX = new DSMyType();
    WS1 ws = new WS1();
    ws.MethodA(dsX);
    }

    The DSMyType is not recreated by the proxy but it is shared in the
    common .dll.
     
    Adrian, Oct 27, 2003
    #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?c3Jp?=

    typed dataset serialization issue in 2.0

    =?Utf-8?B?c3Jp?=, Aug 1, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    450
    =?Utf-8?B?c3Jp?=
    Aug 1, 2006
  2. Peter R Lynch

    Typed Dataset Parameter In A Web Service Method

    Peter R Lynch, Jan 18, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    162
    Peter R Lynch
    Jan 18, 2004
  3. Ketchup
    Replies:
    1
    Views:
    272
    Jan Tielens
    May 25, 2004
  4. Justin Crossley

    Problem passing a typed dataset to a web service

    Justin Crossley, Nov 17, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    160
    Dino Chiesa [Microsoft]
    Nov 18, 2004
  5. N. Shehzad

    returning strongly typed dataset from web service

    N. Shehzad, Mar 2, 2007, in forum: ASP .Net Web Services
    Replies:
    24
    Views:
    722
    John Saunders
    Mar 6, 2007
Loading...

Share This Page