returning (predefined) class objects in Web Services and Dinosaur Brain ...

Discussion in 'ASP .Net Web Services' started by Iain, Jul 5, 2004.

  1. Iain

    Iain Guest

    I have been trying to return a complex object structure to the client of a
    Web Service.

    I've sort of got it working, but ...

    What I was wanting to do (probably because I still live in the Dinosaur age)
    was to include the class definition in the client assembly and have the Web
    Service load the results into this locally defined class. so the code might
    look like

    CommonClasses.ComplexClass myClass = null;

    Proxy.GetStuff(ref myClass);

    but of course this fails, because although the wsdl definition is exactly
    the same as the original xsd and hence the generated class will look the
    same, they are in different namespaces. The SOAP generated class is in the
    Proxy namespace and the original is in CommonClasses.

    Now, in this case I'm just transferring data so I can probably use the class
    created by the Proxy which will be OK.

    But suppose I wanted to transfer a class object with some intelligence?
    such as processing methods of some kind (or even simply intelligent
    indexers)? How could I do this? Is it possible?

    ENglightenment for this dinosaur would be appreciated...

    Iain
     
    Iain, Jul 5, 2004
    #1
    1. Advertising

  2. Iain,

    > I have been trying to return a complex object structure to the client of a
    > Web Service.
    >
    > I've sort of got it working, but ...
    >
    > What I was wanting to do (probably because I still live in the Dinosaur

    age)
    > was to include the class definition in the client assembly and have the

    Web
    > Service load the results into this locally defined class. so the code

    might
    > look like
    >
    > CommonClasses.ComplexClass myClass = null;
    >
    > Proxy.GetStuff(ref myClass);
    >
    > but of course this fails, because although the wsdl definition is exactly
    > the same as the original xsd and hence the generated class will look the
    > same, they are in different namespaces. The SOAP generated class is in

    the
    > Proxy namespace and the original is in CommonClasses.
    >
    > Now, in this case I'm just transferring data so I can probably use the

    class
    > created by the Proxy which will be OK.


    You could manually edit the generated proxy code to remove the redundant
    class definitions. It's a pita, but that's pretty much the way to go right
    now...

    >
    > But suppose I wanted to transfer a class object with some intelligence?
    > such as processing methods of some kind (or even simply intelligent
    > indexers)? How could I do this? Is it possible?


    Well, I'd suggest you think this carefully. Webservices are NOT about
    remoting objects. They are about passing documents (data) around. The two
    things do not fit well together; we've learn that the hard way.

    --
    Tomas Restrepo
     
    Tomas Restrepo \(MVP\), Jul 5, 2004
    #2
    1. Advertising

  3. Iain

    Iain Guest


    > Well, I'd suggest you think this carefully. Webservices are NOT about
    > remoting objects. They are about passing documents (data) around. The two
    > things do not fit well together; we've learn that the hard way.
    >
    > --
    > Tomas Restrepo
    >
    >

    Thanks, Tomas, I'm rapidly coming to this conclusion! Of course it makes a
    nonsense of the name, doesn't it?

    Simple Object Access Protocol - if you can't perform operations on it, it
    isn't an object!

    still.

    I must say the task of getting stuff from SQL and across the wire has been
    considerably nastier and more restrictive than I was expecting. Don't know
    why I keep being so optimistic, but ...

    Iain
     
    Iain, Jul 5, 2004
    #3
  4. Hi Iain,

    > Thanks, Tomas, I'm rapidly coming to this conclusion! Of course it makes

    a
    > nonsense of the name, doesn't it?
    >
    > Simple Object Access Protocol - if you can't perform operations on it, it
    > isn't an object!


    Well, SOAP 1.2 lost that acronym.

    >
    > still.
    >
    > I must say the task of getting stuff from SQL and across the wire has been
    > considerably nastier and more restrictive than I was expecting. Don't

    know
    > why I keep being so optimistic, but ...


    Well, it might be a time to consider in more detail what you're trying to
    solve :) ... or, rather, consider it from a different perspective :)

    --
    Tomas Restrepo
     
    Tomas Restrepo \(MVP\), Jul 5, 2004
    #4
  5. Iain

    Iain Guest

    "Tomas Restrepo (MVP)" <> wrote in message
    news:...
    > Well, it might be a time to consider in more detail what you're trying to
    > solve :) ... or, rather, consider it from a different perspective :)
    >

    Done! As per usual, I've got things working but not how I wanted and as per
    usual, I don't *entirely* understand how ... (the specific thing that I
    don't understand how is that my SQL Server FOR XML EXPLICIT had to have
    xmlns in for the Client side proxy to work, but when the namespace is added
    a nested node which elements in failed to work. Changing the elements to
    attributes fixed that, but I have no idea why....!)

    Thanks


    Iain
     
    Iain, Jul 5, 2004
    #5
  6. Hi Iain,

    > Done! As per usual, I've got things working but not how I wanted and as

    per
    > usual, I don't *entirely* understand how ... (the specific thing that I
    > don't understand how is that my SQL Server FOR XML EXPLICIT had to have
    > xmlns in for the Client side proxy to work, but when the namespace is

    added
    > a nested node which elements in failed to work. Changing the elements to
    > attributes fixed that, but I have no idea why....!)


    It likely has to do with how namespace affect elements vs. Attributes.
    Usually, in most schemas, attributes are not directly qualified (that is,
    they have no namespace prefix), which means that they are supposed to
    naturally "belong" to the same vocabulary their elements belong to. Prefixed
    attributes are usually only used in extension schemas, and the attributes
    get prefixed to signify they belong to a vocabulary different from that the
    element belongs to.

    Elements, however, don't get such treatment ;)
    In the end, I presume what's going on is that you were generating an XML
    that didn't quite fit into the schema you were using....
    --
    Tomas Restrepo
     
    Tomas Restrepo \(MVP\), Jul 5, 2004
    #6
  7. Iain

    Iain Guest

    > Tomas Restrepo wrote

    > It likely has to do with how namespace affect elements vs. Attributes.
    > Usually, in most schemas, attributes are not directly qualified (that is,
    > they have no namespace prefix), which means that they are supposed to
    > naturally "belong" to the same vocabulary their elements belong to.

    Prefixed
    > attributes are usually only used in extension schemas, and the attributes
    > get prefixed to signify they belong to a vocabulary different from that

    the
    > element belongs to.
    >
    > Elements, however, don't get such treatment ;)
    > In the end, I presume what's going on is that you were generating an XML
    > that didn't quite fit into the schema you were using....


    well, yes. but both element and attributes are marked as unqualified in the
    xsd and (for example) the node <DeliveryAddress> in which the missing
    elements should have sat was contained in <Order> itself contained in
    <OrderBatch>, so had it simply been elements vs. attributes I would have
    expected the <DeliveryAddress> element not to have been found.

    Well. getting it working at all is the important thing. I have to admit
    though, that although I would have said I understood namespaces fairly well,
    I do seem to see odd things happening with them...

    Thanks again - just moaning now, really!

    Iain
     
    Iain, Jul 5, 2004
    #7
  8. Iain,

    > well, yes. but both element and attributes are marked as unqualified in

    the
    > xsd and (for example) the node <DeliveryAddress> in which the missing
    > elements should have sat was contained in <Order> itself contained in
    > <OrderBatch>, so had it simply been elements vs. attributes I would have
    > expected the <DeliveryAddress> element not to have been found.
    >
    > Well. getting it working at all is the important thing. I have to admit
    > though, that although I would have said I understood namespaces fairly

    well,
    > I do seem to see odd things happening with them...
    >
    > Thanks again - just moaning now, really!


    Hey, if you want to send me the XML and XSD that were giving you problems,
    I'd be happy to take a look at it and see if I can spot it ;)

    --
    Tomas Restrepo
     
    Tomas Restrepo \(MVP\), Jul 6, 2004
    #8
  9. This may not help in the immediate term, but I wrote up a nifty little
    tutorial for sharing types with Whidbey

    http://aaronthearchitect.com/blog/archive/2004/07/11/190.aspx

    "Iain" <> wrote in message
    news:...
    > I have been trying to return a complex object structure to the client of a
    > Web Service.
    >
    > I've sort of got it working, but ...
    >
    > What I was wanting to do (probably because I still live in the Dinosaur

    age)
    > was to include the class definition in the client assembly and have the

    Web
    > Service load the results into this locally defined class. so the code

    might
    > look like
    >
    > CommonClasses.ComplexClass myClass = null;
    >
    > Proxy.GetStuff(ref myClass);
    >
    > but of course this fails, because although the wsdl definition is exactly
    > the same as the original xsd and hence the generated class will look the
    > same, they are in different namespaces. The SOAP generated class is in

    the
    > Proxy namespace and the original is in CommonClasses.
    >
    > Now, in this case I'm just transferring data so I can probably use the

    class
    > created by the Proxy which will be OK.
    >
    > But suppose I wanted to transfer a class object with some intelligence?
    > such as processing methods of some kind (or even simply intelligent
    > indexers)? How could I do this? Is it possible?
    >
    > ENglightenment for this dinosaur would be appreciated...
    >
    > Iain
    >
    >
     
    Aaron A. Anderson, Jul 12, 2004
    #9
  10. Iain

    Rick Spiewak Guest

    Did you actually succeed in solving this problem (transmitting custom class
    objects over Web Services)?
    If so, I'd really be interested in seeing how!

    "Iain" <> wrote in message
    news:...
    > I have been trying to return a complex object structure to the client of a
    > Web Service.
    >
    > I've sort of got it working, but ...
    >
    > What I was wanting to do (probably because I still live in the Dinosaur

    age)
    > was to include the class definition in the client assembly and have the

    Web
    > Service load the results into this locally defined class. so the code

    might
    > look like
    >
    > CommonClasses.ComplexClass myClass = null;
    >
    > Proxy.GetStuff(ref myClass);
    >
    > but of course this fails, because although the wsdl definition is exactly
    > the same as the original xsd and hence the generated class will look the
    > same, they are in different namespaces. The SOAP generated class is in

    the
    > Proxy namespace and the original is in CommonClasses.
    >
    > Now, in this case I'm just transferring data so I can probably use the

    class
    > created by the Proxy which will be OK.
    >
    > But suppose I wanted to transfer a class object with some intelligence?
    > such as processing methods of some kind (or even simply intelligent
    > indexers)? How could I do this? Is it possible?
    >
    > ENglightenment for this dinosaur would be appreciated...
    >
    > Iain
    >
    >
     
    Rick Spiewak, Jul 15, 2004
    #10
    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. lovecreatesbeauty
    Replies:
    3
    Views:
    2,977
    lovecreatesbeauty
    May 19, 2005
  2. Mike Holme
    Replies:
    0
    Views:
    317
    Mike Holme
    Aug 15, 2006
  3. pataphor
    Replies:
    0
    Views:
    440
    pataphor
    Jun 14, 2009
  4. Eustaquio Rangel de Oliveira Jr.
    Replies:
    4
    Views:
    157
    Robert Klemme
    Jul 5, 2005
  5. Tony Nelson
    Replies:
    3
    Views:
    106
    Lasse Reichstein Nielsen
    Sep 8, 2008
Loading...

Share This Page