![]() |
Table of Contents
soap4rInstall soap4rThe soap4r module is bundled with modern versions of Ruby. The latest version is also available as a Ruby Gem or as a download from the soap4r web site. For package based platforms (e.g. Ubuntu, CentOS, etc.) check if a package exists before installing from a Ruby Gem or download. Using soap4r
For example: using WSDbfetch to get fasta formatted sequence for the UniProtKB protein ALK1_HUMAN Load the soap4r library: require 'soap/wsdlDriver' Get the service proxy for the service: # URL for the service WSDL wsdl = 'http://www.ebi.ac.uk/ws/services/WSDbfetch?wsdl' # Get the object from the WSDL dbfetchSrv = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver For debugging it is useful to see the SOAP messages being passed between the client and the server: dbfetchSrv.wiredump_dev = STDOUT
Get the data from the service and print it: puts dbfetchSrv.fetchData("UNIPROT:ADH1A_HUMAN", "fasta", "raw") All the methods in the WSDbfetch service take simple strings as arguments. For complex data types such as those used in the WSFasta service nested hash data structures are used to represent the type. For example: submitting a job to WSFasta: # Query sequence seq = ">Q8E5Q5_STRA3 MKLSKRYRFWQKVIKALGVLALIATLVLVVYLYKLGILNDSNELKDLVHKYEFWGPMIFI VAQIVQIVFPVIPGGVTTVAGFLIFGPTLGFIYNYIGIIIGSVILFWLVKFYGRKFVLLF MDQKTFDKYESKLETSGYEKFFIFCMASPISPADIMVMITGLSNMSIKRFVTIIMITKPI SIIGYSYLWIYGGDILKNFLN" # Get the object from the WSDL fastaSrv = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver # Set the parameters for the job params = {} params['program'] = 'ssearch' params['database'] = 'swissprot' params['email'] = 'your@email' params['async'] = 1 # Build the data structure data = [{'type'=>'sequence', 'content'=>seq}] # Submit the job jobId = fastaSrv.runFasta(params, data) puts jobId Given the job identifier we poll until the job completes: # Use the job identifier to check the status of the job status = 'RUNNING' while status=='RUNNING' sleep 10 status = fastaSrv.checkStatus(jobId) puts status end And if the job completed successfully, retrieve the result: # When finished get the result if status=='DONE' puts fastaSrv.polljob(jobId, 'tooloutput') end ExamplesSample ClientsMost SOAP Web Services at EMBL-EBI have sample clients which provide command-line access to the service and example code. For Ruby these clients are based on soap4r. Document/literal SOAP
RPC/encoded SOAP![]() |