This list should work as guide when creating new web service in BASE.
Create a new class that extends
AbstractRPCService
Place the new service in same package as the abstract class,
net.sf.basedb.ws.server
Write the routines/methods the service should deploy.
Never return void from methods | |
---|---|
For server-side exceptions to be propagated to the client the web services method mustn't be declared as void. We suggest that in cases where there is no natural return value, the session ID is returned, for example: public String myMethod(String ID, ...more parameters...) { // ... your code here return ID; } |
Make the Ant build-file creates a WSDL-file when the services are compiled (see below). This step is not needed for BASE to work but may be appreciated by client application developers.
Register the service in the
<base-dir>/src/webservices/server/META-INF/services.xml
file. This is an XML file listing all services and is needed
for BASE (Axis) to pick up the new service and expose it to the
outside world. Below is an example of hoe the Session
service is registered.
Example 28.1.
How to register a service in
services.xml
<service name="Session" scope="application"> <description> This service handles BASE sessions (including login/logout) </description> <messageReceivers> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" /> </messageReceivers> <parameter name="ServiceClass" locked="false">net.sf.basedb.ws.server.SessionService</parameter> </service>
When a new service is created it can be a good idea to also get a WSDL-file
generated when the web services are compiled. The WSDL-file will be a help for those
developers who intend to create client applications to the new service. It is a
one-liner in the Ant build file to do this and not very complicated.
To create a WSDL file for the new web service add a line like the one
below to the webservices.wsdl
target. Replace
SessionService
with the name of the new service class.
<webservices.wsdl serviceClassName="SessionService"/>