Typed dataset used by two webservices problem

Discussion in 'ASP .Net Web Services' started by Simon Storr, Feb 23, 2004.

  1. Simon Storr

    Simon Storr Guest

    I have two webservices, for arguments sake FredWS and JimWS. They both
    contain webmethods which have a typed dataset JoeDataset as a parameter. If
    I add a web reference to FredWS (called FredWSProxy) then a class named
    FredWSProxy.JoeDataset will be created mapping to JoeDataset (similarly
    JimWSProxy.JoeDataset for a web reference to JimWS).

    Now in my web app I have a function which calls FredWS returning a
    FredWSProxy.JoeDataset. The problem arises when I want to pass this dataset
    to JimWSProxy - I can't due to an invalid typecast! Is there a way around
    this or do I really have to move all my code into one big webservice?

    Also the code generated by the typed dataset xsd generator is huge - is
    there any way to 'turn off' sections of code that we don't use from being
    generated (all the async stuff for instance?)

    Thanks in advance,

    Simon
    Simon Storr, Feb 23, 2004
    #1
    1. Advertising

  2. Simon Storr

    richlm Guest

    One approach I have seen is not to pass dataset directly, but wrap it in an
    XML document
    e.g.
    [WebMethod]
    public XmlDocument GetJoeDataset()
    {
    return new XmlDataDocument(_JoeDataset);
    }

    You'll still have to do the work of type checking against a XML schema - we
    have moved from compile-time-type-checking to run-time-type-checking.
    If you have an .xsd you can still re-create a dataset at the client, if
    that's what you need.
    Here's a couple of articles that discuss this approach:
    http://msdn.microsoft.com/msdnmag/issues/03/04/XMLFiles/default.aspx
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service02112003.asp

    It is not just the proxy code that is huge - the serialized message can be
    pretty big too - which the above approach does not solve.

    Another "idea" (quick & dirty solution...) could be to use Dataset.Merge to
    perform the type conversion. Of course this is a deep copy - but then so is
    serializing across the wire, so if you can accept the overhead perhaps this
    might work for you.

    I prefer to think of web services as a message-based protocol more than a
    RPC-type protocol - and therefore serialized XML (which I control) often
    fits more naturally than complex types (especially ones native to .NET).
    That's just my opinion - there are of course many viewpoints on this.

    Hope this helps.
    Richard.


    "Simon Storr" <> wrote in message
    news:eASJ0Zi%...
    > I have two webservices, for arguments sake FredWS and JimWS. They both
    > contain webmethods which have a typed dataset JoeDataset as a parameter.

    If
    > I add a web reference to FredWS (called FredWSProxy) then a class named
    > FredWSProxy.JoeDataset will be created mapping to JoeDataset (similarly
    > JimWSProxy.JoeDataset for a web reference to JimWS).
    >
    > Now in my web app I have a function which calls FredWS returning a
    > FredWSProxy.JoeDataset. The problem arises when I want to pass this

    dataset
    > to JimWSProxy - I can't due to an invalid typecast! Is there a way around
    > this or do I really have to move all my code into one big webservice?
    >
    > Also the code generated by the typed dataset xsd generator is huge - is
    > there any way to 'turn off' sections of code that we don't use from being
    > generated (all the async stuff for instance?)
    >
    > Thanks in advance,
    >
    > Simon
    >
    >
    richlm, Feb 23, 2004
    #2
    1. Advertising

  3. Hello Simon,

    Do you have any more concerns on Richard's suggestion? Please feel free to
    post here if there is any more questions.

    Thanks very much.

    Best regards,
    Yanhong Huang
    Microsoft Community Support

    Get Secure! ┬ĘC www.microsoft.com/security
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Yan-Hong Huang[MSFT], Feb 26, 2004
    #3
    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. Nedu N
    Replies:
    1
    Views:
    1,775
    Chris Taylor
    Oct 31, 2003
  2. Nedu N
    Replies:
    2
    Views:
    2,142
  3. William Gower
    Replies:
    2
    Views:
    4,112
    Brian Baker [MVP]
    Jul 26, 2004
  4. thomson
    Replies:
    2
    Views:
    14,818
    Eliyahu Goldin
    Jan 19, 2005
  5. Nedu N
    Replies:
    2
    Views:
    210
    Jacob Yang [MSFT]
    Oct 31, 2003
Loading...

Share This Page