Sending / returning objects

M

Morten

Hi!

I'm trying to figure out if it's possible to create an object in a
webservice, return it (the object / representation of an object) to a
client, make modifications on the client and push the changes back to the
webservice?

I'm guessing that you have to use remoting obejcts for something like this
but I don't believe that will prove to be platform independent so that won't
work in our environment.

Any input is most welcome!

Morten
 
D

Dino Chiesa [Microsoft]

Web services is a message-passing paradigm, not an object-remoting paradigm.
It is possible to code an object and serialize its state to XML.
You can ship that XML back-and-forth on a wire, modify it on either side.
And at the end of this exchange, you can de-serialize from XML and
instantiate an object from it once again.

But as you can see, it is not the same object, it is a new object entirely.
If your app can deal with this, then YES, you can accomplish what you want.
On the other hand if you require that it be the SAME object, you have some
more work to do.

-D
 
M

Morten

Hmm... Not entirely sure that I understand. Does this mean that I can get a
copy of an object on the client, modify it using the normal methods - like
the ones in my web service - and have these modifications take place in my
webservice once I commit them?

Best regards

Morten
 
J

Jeffrey Hasan

As Dino pointed out, Web services are designed to exchange messages, which
can correspond to an "object" as long as you have generated an XSD schema
representation for the object. Web services are not designed to exhanged
stateful "objects" across the wire in the same way that .NET Remoting allows
you to do. And Web services cannot exchange "objects" that define their own
methods. However, you can approximate this behavior to exchange an object
with properties, as follows:

1. Generate an XSD schema representation of the object.
2. On the client, instance the object, set its properties, serialize it to
XML and pass it to a Webmethod that is capable of accepting the object.
3. In the Web method, deserialize the XML and hydrate a new instance of the
object.
4. In the Web method set/reset the properties as needed.
5. Set the return type for the Web method to the object.

The schema is important so that both client and service have an independent
reference to an object type, since they must share a common understanding of
this type.

Final note: in VS.NET, all of the above can be accomplished by writing a
type assembly for the object and referencing it in both client and service

Hope this helps.

Jeffrey Hasan, MCSD
President, Bluestone Partners, Inc.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top