passing objects to web service

View: New views
6 Messages — Rating Filter:   Alert me  

passing objects to web service

by wakeup :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not sure which is the best form to passing objects in web services. How do you do it?

- Returning the class?   public myclas exampleMethod()
- Returning a XML string?   public string exampleMethod()
- Another form?

Thanks


__________________
Hip Hop
Chistes

Re: passing objects to web service

by Arthur Ryman-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Just say no.

Don't view Web services as a distributed object technology. View it as message exchange technology. Design your messages as nice, easy to understand XML documents and then you can bind them to objects inside your implementation. If you use an implementation language like Java or C#, you can generate code from the XML document description, i.e. the XSD, that is part of the Web service description (WSDL).

Arthur Ryman,
IBM Software Group, Rational Division

blog: http://ryman.eclipsedevelopersjournal.com/
phone: +1-905-413-3077, TL 969-3077
assistant: +1-905-413-2411, TL 969-2411
fax: +1-905-413-4920, TL 969-4920
mobile: +1-416-939-5063, text: 4169395063@...



"wakeup (sent by Nabble.com)" <lists@...>
Sent by: www-ws-desc-request@...

03/31/2006 06:52 AM
Please respond to
wakeup <alainc@...>

To
www-ws-desc@...
cc
Subject
passing objects to web service







I'm not sure which is the best form to passing objects in web services. How
do you do it?

- Returning the class?   public myclas exampleMethod()
- Returning a XML string?   public string exampleMethod()
- Another form?

Thanks


__________________
Hip Hop
Chistes

--
View this message in context: http://www.nabble.com/passing-objects-to-web-service-t1374219.html#a3687980
Sent from the w3.org - www-ws-desc forum at Nabble.com.




Re: passing objects to web service

by wakeup :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Then you recomend this?
Returning a XML string?   public string exampleMethod()

But with this option, you spend time formatin xml to objects, I'm not sure.

RE: passing objects to web service

by Rogers, Tony :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Re: passing objects to web service
I don't believe Arthur was advocating returning a string.
 
Speaking for myself, I think you are mixing layers. The string / XML is the transmission format. If you are using an RPC model, then you should be thinking of the internal model when defining the RPC signature, not the way in which it is transmitted. You should define a structured object that you want returned, and specify that in the method's signature.
 
Assuming that you have a structured object type called, for example, MyStructuredType, then the signature should be:
 
   public MyStructuredType exampleMethod()
 
The fact that this type will be transmitted as XML is irrelevant to the method signature. That fact only becomes relevant when defining the WSDL that will describe the call. That's a different layer.
 
Does that clarify things?
 
Tony Rogers


From: www-ws-desc-request@... on behalf of wakeup (sent by Nabble.com)
Sent: Mon 03-Apr-06 17:09
To: www-ws-desc@...
Subject: Re: passing objects to web service



Then you recomend this?
Returning a XML string?   public string exampleMethod()

But with this option, you spend time formatin xml to objects, I'm not sure.
--
View this message in context: http://www.nabble.com/passing-objects-to-web-service-t1374219.html#a3720932
Sent from the w3.org - www-ws-desc forum at Nabble.com.




RE: passing objects to web service

by wakeup :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ah ok, then you recommend me send objects?

And is it compatible with clients in another programmin language?


Re: passing objects to web service

by Arthur Ryman-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


No.

There are two approaches that work well.

1. Design an XML schema for you input and output messages, put those in the WSDL and then use a tool to generate code from WSDL, and fill in the implementation of the code by delegating to your existing objects.

2. Design data transfer objects in you programming language and write a wrapper class for you existing code. The wrapper uses the data transfer objects in its method signature and its implementation delegates to you existing object. Then generate WSDL for your wrapper class instead of your original code.

Both of these approaches produce simple XML messages that can be easily processed by other clients.

Arthur Ryman,
IBM Software Group, Rational Division

blog: http://ryman.eclipsedevelopersjournal.com/
phone: +1-905-413-3077, TL 969-3077
assistant: +1-905-413-2411, TL 969-2411
fax: +1-905-413-4920, TL 969-4920
mobile: +1-416-939-5063, text: 4169395063@...



"wakeup (sent by Nabble.com)" <lists@...>
Sent by: www-ws-desc-request@...

04/03/2006 03:09 AM
Please respond to
wakeup <alainc@...>

To
www-ws-desc@...
cc
Subject
Re: passing objects to web service







Then you recomend this?
Returning a XML string?   public string exampleMethod()

But with this option, you spend time formatin xml to objects, I'm not sure.
--
View this message in context: http://www.nabble.com/passing-objects-to-web-service-t1374219.html#a3720932
Sent from the w3.org - www-ws-desc forum at Nabble.com.