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

I

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.

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
 
T

Tomas Restrepo \(MVP\)

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.
 
I

Iain

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.
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
 
T

Tomas Restrepo \(MVP\)

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 :)
 
I

Iain

Tomas Restrepo (MVP) said:
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
 
T

Tomas Restrepo \(MVP\)

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....
 
I

Iain

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
 
T

Tomas Restrepo \(MVP\)

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 ;)
 
R

Rick Spiewak

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!
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top