BACK

MobyCoreService API

An experimental asynchronous services are based on WSRF implementation. The can be executed using MobyCore API in the same way as usual (RPC-encoded) asynchronous services. An asynchronous BioMoby service must implement several operations:
call()
submit()
getResourceProperty()
getMultipleResourceProperties()
destroy()

Here is an example of service implementation:

@Addressing
@MobyWSRFScope
@MTOM(enabled=true)
@BindingType(value = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT,
             use=SOAPBinding.Use.LITERAL,
             parameterStyle=SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({PropertyResponseWrapper.class}) // let the server know that we use LSAE event to properly handle it
@WebService(serviceName="MobyAsyncDemoService", name="MobyAsyncDemoService", targetNamespace="http://biomoby.org/")
public class MobyAsyncDemoService extends AbstractAsyncMobyService
{
    @Resource
    private WebServiceContext ctx;

    private MobyAsyncDemoImpl impl;
    
    public MobyAsyncDemoService()
    {
        impl = new MobyAsyncDemoImpl();
    }

    @Override
    public IAsyncMobyImpl getAsyncMobyImpl()
    {
        return impl;
    }

    @Override
    public WebServiceContext getWebServiceContext()
    {
        return ctx;
    }

    @Override
    @WebMethod(operationName="MobyAsyncDemoService", action="http://biomoby.org/#MobyAsyncDemoService")
    @WebResult(name="MOBY", targetNamespace="http://www.biomoby.org/moby")
    public MobyMessage call(@WebParam(name="MOBY", targetNamespace="http://www.biomoby.org/moby", mode = WebParam.Mode.IN) MobyMessage message)
    {
        return super.call(message);
    }

    @Override
    @WebMethod(operationName="MobyAsyncDemoService_submit", action="http://biomoby.org/#MobyAsyncDemoService_submit")
    @WebResult(name="MobyAsyncDemoService_submitResponse", targetNamespace="http://biomoby.org/")
    public SubmitResponseWrapper submit(@WebParam(name="MOBY", targetNamespace="http://www.biomoby.org/moby", mode=WebParam.Mode.IN) MobyMessage message)
    {
        return super.submit(message);
    }

    @Override
    @Action(
      input="http://docs.oasis-open.org/wsrf/rpw-2/GetResourceProperty/GetResourcePropertyRequest",
      output="http://docs.oasis-open.org/wsrf/rpw-2/GetResourceProperty/GetResourcePropertyResponse")
    @WebMethod(operationName = "GetResourceProperty")
    @WebResult(name = "GetResourcePropertyResponse", targetNamespace = "http://docs.oasis-open.org/wsrf/rp-2", partName = "GetResourcePropertyResponse")
    @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
    public GetResourcePropertyResponse getResourceProperty(
        @WebParam(name = "GetResourceProperty", targetNamespace = "http://docs.oasis-open.org/wsrf/rp-2", partName = "GetResourcePropertyRequest")
        QName getResourcePropertyRequest)
        throws InvalidResourcePropertyQNameFault, ResourceUnavailableFault, ResourceUnknownFault
    {
        return super.getResourceProperty(getResourcePropertyRequest);
    }

    @Override
    @Action(
      input="http://docs.oasis-open.org/wsrf/rpw-2/GetMultipleResourceProperties/GetMultipleResourcePropertiesRequest",
      output="http://docs.oasis-open.org/wsrf/rpw-2/GetMultipleResourceProperties/GetMultipleResourcePropertiesResponse")
    @WebMethod(operationName = "GetMultipleResourceProperties")
    @WebResult(name = "GetMultipleResourcePropertiesResponse", targetNamespace = "http://docs.oasis-open.org/wsrf/rp-2", partName = "GetMultipleResourcePropertiesResponse")
    public GetMultipleResourcePropertiesResponse getMultipleResourceProperties(
        @WebParam(name = "GetMultipleResourceProperties", targetNamespace = "http://docs.oasis-open.org/wsrf/rp-2", partName = "GetMultipleResourcePropertiesRequest")
        GetMultipleResourceProperties getMultipleResourcePropertiesRequest)
        throws InvalidResourcePropertyQNameFault, ResourceUnavailableFault, ResourceUnknownFault
    {
        return super.getMultipleResourceProperties(getMultipleResourcePropertiesRequest);
    }
    
    @Override
    @Action(
      input="http://docs.oasis-open.org/wsrf/rpw-2/QueryResourceProperties/QueryResourcePropertiesRequest",
      output="http://docs.oasis-open.org/wsrf/rpw-2/QueryResourceProperties/QueryResourcePropertiesResponse")
    @WebMethod(operationName = "QueryResourceProperties")
    @WebResult(name = "QueryResourcePropertiesResponse", targetNamespace = "http://docs.oasis-open.org/wsrf/rp-2", partName = "QueryResourcePropertiesResponse")
    @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
    public QueryResourcePropertiesResponse queryResourceProperties(
        @WebParam(name = "QueryResourceProperties", targetNamespace = "http://docs.oasis-open.org/wsrf/rp-2", partName = "QueryResourcePropertiesRequest")
        QueryResourceProperties queryResourceProperties)
        throws UnknownQueryExpressionDialectFault, InvalidQueryExpressionFault, QueryEvaluationErrorFault
    {
        return super.queryResourceProperties(queryResourceProperties);
    }

    @Override
    @Action(
      input="http://docs.oasis-open.org/wsrf/rlw-2/ImmediateResourceTermination/DestroyRequest",
      output="http://docs.oasis-open.org/wsrf/rlw-2/ImmediateResourceTermination/DestroyResponse")
    @WebMethod(operationName = "Destroy")
    @RequestWrapper(localName = "Destroy", targetNamespace = "http://docs.oasis-open.org/wsrf/rl-2", className = "org.inb.wsrf.rl2.Destroy")
    @ResponseWrapper(localName = "DestroyResponse", targetNamespace = "http://docs.oasis-open.org/wsrf/rl-2", className = "org.inb.wsrf.rl2.DestroyResponse")
    public void destroy()
        throws ResourceNotDestroyedFault, ResourceUnavailableFault, ResourceUnknownFault
    {
        super.destroy();
    }
}

Where the "real" implementation class is a MobyAsyncDemoImpl:

public class MobyAsyncDemoImpl extends AbstractAsyncMobyImpl
{
    private MobyMessage message;

    /**
     * An implementator may override this method to provide a custom serviceInvocationId
     */
    public String getServiceInvocationId()
    {
        return null;
    }

    public MobyMessage call(MobyMessage message)
    {
        System.out.println("[MobyAsyncDemoImpl].call()");
        
        return message;
    }

    public void submit(MobyMessage message)
    {
        System.out.println("[MobyAsyncDemoImpl].submit()");
        
        // just store the message to return it later (test)
        this.message = message;
    }

    public MobyMessage getResourcePropertyResult() throws ResourceUnavailableFault
    {
        return message;
    }

    public AnalysisEvent getResourcePropertyStatus(String queryID) throws InvalidResourcePropertyQNameFault, ResourceUnavailableFault, ResourceUnknownFault
    {
        System.out.println("[MobyAsyncDemoImpl].getResourcePropertyStatus()");
        
        AnalysisEvent event = new AnalysisEvent();
        event.setId(queryID);
        event.setMessage("test event");
        
        StateChanged stateChanged = new StateChanged();
        stateChanged.setNewState(StateChanged.STATE.completed);
        
        event.setEvent(stateChanged);
        
        return event;
    }

    public void destroy() throws ResourceNotDestroyedFault, ResourceUnavailableFault, ResourceUnknownFault
    {
        System.out.println("[MobyAsyncDemoImpl].destroy()");
    }
}