On Mon, Jul 26, 2010 at 7:28 PM, Zoran Jeremic <[email protected]> wrote: > Hi, > > I've created Tuscany Web service that returns an instance of Java class. > Then I work locally on this class and change it's properties. However, when > I access the same instance from web service, there is no change on it's > properties. As I'm new with tuscany I'm wondering if this java instance I > get through tuscany behaves as the same instance or as another instance? Do > I have to pass and change the old instance with the updated one? > > Thanks > >
Hi The short answer is yes you are working with a copy of the original object. When you communicate with a service using Web Services you are using a remote interface. In SCA terms the service's Java interface must be marked as @Remotable (there are other ways that it can be marked as remotable but I'm skipping over those for the purpose of this explanantion). A remote interface allows you to communicate with services regardless of where they are running. For example, the service could be running on a completely separate machine from component that's calling it. Hence the use of the term remote. To make this work, remote interfaces always exploit pass by value semantics. By this we mean that when an object is passed into the remote service or when the remote service returns an object a copy (the value) of the object is passed rather than a reference to the original object. This must be the case because, when using protocols such as SOAP/HTTP, the object will be serialized out to XML to be sent. When the XML is received it is converted back into the right sort of object. As you can imagine you can't do this sort of thing while maintaining an reference to the original object. Hence when you make changes to the object that has been returned to you in the client component the original object in the service is not changed. To change the object in the service you'll have to arrange to send the changes back to the service. You'll need to devise a service interface to allow this to happen. Hope that helps Simon -- Apache Tuscany committer: tuscany.apache.org Co-author of a book about Tuscany and SCA: tuscanyinaction.com
