Hi there,
I'm looking for some advice on starting out creating web services with Spring WS.
Have been reading Spring Web Services - Reference Documentation 1.5.2, as well as the chapter on web services in the Spring Reference Documentation 2.5.4, as well as searching the forums, and I'm sure I'm missing something.
I would like to define my web services using a purely annotation based approach, without the need for writing any wsdl xml, and without needing to define callback objects, parse xml in my service objects. I'd like to just deal with POJO's.
I would like a setup whereby I call a local object and it "automagically" calls the same methods on the remote object. I would like to deploy the service using a servlet (WAR) and to deploy both client and service on Java 5 (Websphere).
I could see that creating the server part was fairly straight forward, in that you define your annotated service endpoint, make it available via the MesageDispatcherServlet and deploy. However it is the client part I found difficult. I want a way of grabbing the a local object (assume to be proxied) and simply call the methods, which invokes the same methods on the remote service, returning appropriate values. Sort of a similar behaviour to some of the older RMI apps I've written.
I'm finding the forums and doc quite confusing, as it seems this part of spring is rather "fast moving" advice depends a lot on JVM and Spring versions.
Any advice on this would be greatly appreciated.
Apologies if I'm asking for too much!
Current code is below:
My spring-ws-servlet.xml
My endpoint class:Code:<beans> <bean id="orderEndpoint" class="com.ben.service.BusinessServiceEndpoint"/> <bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter"> <constructor-arg ref="marshaller" /> </bean> <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <property name="classesToBeBound"> <list> <value>com.ben.model.BusinessObject</value> </list> </property> </bean> <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping" /> </beans>
My business model object:Code:package com.ben.service; import org.springframework.ws.server.endpoint.annotation.Endpoint; import org.springframework.ws.server.endpoint.annotation.PayloadRoot; import com.ben.model.BusinessObject; @Endpoint public class BusinessServiceEndpoint { @PayloadRoot(localPart="businessObjectRequest", namespace="...") public BusinessObject getBusinessObject(){ BusinessObject o = new BusinessObject(); o.setBusinessValue("blah"); return o; } }
Is there a config I can do on the client, which will give me something like:Code:package com.anz.pb.directory.model; public class BusinessObject { private String businessValue; public String getBusinessValue(){ return businessValue; } public void setBusinessValue(String businessValue){ this.businessValue = businessValue; } }
Kind regards,Code://Injected bean BusinessServiceEndpoint service; //And fetch the remote object through ws BusinessObject obj = service.getBusinessObject();
Ben Warner



Reply With Quote