Back to SABIO-RK Home
          CONTACT | HELP | IMPRINTSample Client Code


Instructions for Accessing the SABIO-RK Web Service                   Back to Web Service Home

This short tutorial will guide you through accessing the SABIO-RK Web service from a simple client. The Web service has so far been tested with Java, Perl and Python clients, but in principle it can be accessed via any client coded in a language which is capable of processing SOAP/WSDL, such as C# and Ruby. We will be shortly testing and placing code for these languages on this page.

Creating a Java Client

Before we create a Java client to access the Web service, we first need to download the Apache Axis API Opens a new window. Download the latest release (1.4, at the time of writing this), and unpack it to a directory (INSTALLDIRECTORY). We are interested in the libraries in this distribution, which are in the following subdirectory:

INSTALLDIRECTORY/lib/

You can add all the libraries in your System CLASSPATH. However, below we will manually include these libraries in the classpath.

The Sabio-RK Web service is a Document/Literal style Web service, as described in the WSDL file. Our first order of business is to generate the Service Endpoint Interface (SEI) using the WSDL2Java tool provided in the axis distribution. Change directory into the lib directory mentioned above, and issue the following command:


>java -cp axis.jar;axisjava-ant.jar;commons-discovery-0.2.jar;commons-logging1.0.4.jar;jaxrpc.jar;log4j-1.2.8.jar;saaj.jar;wsdl4j-1.5.1.jar org.apache.axis.wsdl.WSDL2Java http://sabio.bioquant.uni-heidelberg.de/sabiork?wsdl -Nhttp://localhost:8084/SpringingSabioRk/sabiork=org.eml.sdbv.sabioclient -W

The first argument to the WSDL2Java command is the URL of the Sabio-RK Web service.
The ?N option allows you to map the target namespace used in the WSDL file to a package. In the example above, we map the target namespace in the Sabio-RK WSDL file to the package org.eml.sdbv.sabioclient.
The ?W option is required in case you are using a Document style Web service.

The above command will create the following sub-directory structure, and place the generated code there.


INSTALLDIRECTORY/lib/org/eml/sdbv/sabioclient/

You can now use the generated code in the above directory to code your client to customize access to the Sabio-RK Web service (Have a peek in the above directory). The following listing provides sample client code:

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;

import org.eml.sdbv.sabioclient.*;
//import the generated code

public class MyClient
{
public static void main(String [] args) {

  try{

     //Create the service object from the auto-gen class
     Sabiork_ServiceLocator service = new Sabiork_ServiceLocator();

     //Get the port type from the auto-gen method provided in ServiceLocator.
     Sabiork_PortType spt = service.get_8();

     //Instantiate the auto-gen class for the corresponding
     //Web service method you are interested in.

     org.eml.sdbv.sabioclient.GetTissue gt = new org.eml.sdbv.sabioclient.GetTissue();

     //use the methods provided by this object to set the parameters
     gt.setArg0(1234);

     //Axis also wraps the response into the following
     //(as is evident by looking at the auto-generated code)

     org.eml.sdbv.sabioclient.GetTissueResponse gtr = spt.getTissue(gt);

     System.out.println("Result = "+gtr.get_return());
     //and you're done.

   }
   catch (Throwable t) {
   t.printStackTrace();
   }
  }
}


Compile and run the client:

>javac -cp ./axis.jar;./axis-ant.jar;./jaxrpc.jar; MyClient.java

>java -cp ./axis.jar;./axis-ant.jar;./jaxrpc.jar;./commons-discovery-0.2.jar;./commons-logging-1.0.4.jar;./log4j-1.2.8.jar;./saaj.jar;./wsdl4j-1.5.1.jar; MyClient




Creating a Python Client

Before we create a Python client to access the Web service, we first need to download and install the suds library.

Execute the following code:


     #!/usr/bin/python
     from suds.client import Client
     url="http://sabiork.h-its.org/sabiork?wsdl"
     client = Client(url)
     print client.service.getPathwayNames("ABC")




© HITS gGmbH