This page last changed on Apr 22, 2008 by edawson.

Module descriptor

A SOAP RPC plugin module descriptor looks like this:

<rpc-soap key="my.foo.service" path="/foo" class="com.yoydyne.rpc.FooServiceImpl"/>

The descriptor is simple, because much of the configuration is defined by JAX-WS annotations on the implementing class.

The descriptor above defines a SOAP endpoint at http://<your server>/<your context>/service/foo. The WSDL for the service is available at http://<your server>/<your context>/service/foo?wsdl

Service Implementation

The Java implementation looks like this:

@WebService(endpointInterface = "com.yoydyne.rpc.FooService", name = "Foo", serviceName = "Foo")
@SOAPBinding(style = Style.RPC, use = Use.LITERAL)
public class FooServiceImpl implements FooService, SecuredRpcService {
    @Autowired
    private TxTemplate txTemplate;

    public ReviewData createReview(String token, ReviewData review) {
        return reviewService.createReview(review);
    }

    public String doSomething(String token, String arg) {
        return txTemplate.execute(new TxCallback<String>() {
            public String doInTransaction(TransactionStatus status) {
                return "Logged in as " + txTemplate.getEffectivePrincipal();
            }
        });
    }

    public WebServiceContext getContext() {
        return context;
    }

    @Resource
    public void setContext(WebServiceContext context) {
            this.context = context;
    }
}

Note the following points from the code above:

  1. The WebService annotation specifies the interface which this endpoint implements and the name of the endpoint in the generated WSDL
  2. If your implementation extends SecuredRpcService then users must pass a valid login token to requests (unless they are using 10. Trusted Applications). Each method on your interface must take a String as its first parameter, and clients must pass a token returned by the login method of the auth SOAP endpoint. Your implementation ignores this parameter – it is processed by a Spring interceptor. If no valid token is provided, the current user will be the anonymous user.
  3. The class is autowired by Spring, so it can use any Spring beans available in the Fisheye/Crucible Spring context. For example, the TxTemplate is automatically injected into the instance by Spring. This could also have been achieved by defining a method public void setTxTemplate(TxTemplate txTemplate) {...} rather than using the @Autowired annotation.
  4. All SOAP RPC endpoint implementations must include the setContext/getContext methods and the @Resource annotation on setContext.
Document generated by Confluence on Sep 23, 2008 01:42