#!/usr/opt/java # Description: Client script in Java (apache) running the RNAmmer Web Service # Author: Karunakar Bayyapu # Email: karun@cbs.dtu.dk # Version: 1.2 ws1 # Date: 2012-04-23 //### for installation and usage notes please see below //### client code starts here package javaapplication; public class Client { public static void main(String[] args) { try { //runService --You need to change the sequences and ids as per your requirement. //organism and method are optional as per wsdl document WSRNAmmer12ws1_Service service = new WSRNAmmer12ws1_Service(); ObjectFactory objectFactory = new ObjectFactory(); RunService.Parameters parameters = objectFactory.createRunServiceParameters(); Sequencedata sequencedata = objectFactory.createSequencedata(); Sequence sequence1 = objectFactory.createSequence(); sequence1.setId("IPI:IPI00000006.1"); sequence1.setSeq("MTEYKLVVVGAGGVGKSALTIQLIQNHFVDEYDPTIEDSYRKQVVIDGETCLLDILDTAG QEEYSAMRDQYMRTGEGFLCVFAINNTKSFEDIHQYREQIKRVKDSDDVPMVLVGNKCDL AARTVESRQAQDLARSYGIPYIETSAKTRQGVEDAFYTLVREIRQHKLRKLNPPDESGPG CMSCKCVLS"); sequencedata.getSequence().add(sequence1); Sequence sequence2 = objectFactory.createSequence(); sequence2.setId("IPI:IPI00000005.1"); sequence2.setSeq("MTEYKLVVVGAGGVGKSALTIQLIQNHFVDEYDPTIEDSYRKQVVIDGETCLLDILDTAG QEEYSAMRDQYMRTGEGFLCVFAINNSKSFADINLYREQIKRVKDSDDVPMVLVGNKCDL PTRTVDTKQAHELAKSYGIPFIETSAKTRQGVEDAFYTLVREIRQYRMKKLNSSDDGTQG CMGLPCVVM"); sequencedata.getSequence().add(sequence2); parameters.setSequencedata(sequencedata); RunServiceResponse.Queueentry result = service.getWSRNAmmer12ws1().runService(parameters); System.out.println(result.toString()); //pollQueue --jobid needs to be changed as which you got from runService PollQueue.Job job = objectFactory.createPollQueueJob(); job.setJobid("216E97C8-429F-11E1-ACA9-C966F6AC78EB"); PollQueueResponse.Queueentry pr = service.getWSRNAmmer12ws1().pollQueue(job); System.out.println(pr.toString()); //fetchResult --jobid needs to be changed as which you got from runService FetchResult.Job job1 = objectFactory.createFetchResultJob(); job1.setJobid("216E97C8-429F-11E1-ACA9-C966F6AC78EB"); Anndata ann = service.getWSRNAmmer12ws1().fetchResult(job1); System.out.println(ann.toString()); } catch(Exception ex) { ex.printStackTrace(); } } } //### client code ends here //######################################################################################### //############################# ############################# //############################# DOCUMENTATION ############################# //############################# ############################# //######################################################################################### // Introduction: // // We developed simple Java client to test SOAP Webservices. It uses following version // softwares, Libraries and IDE's // * Install Java JDK(1.6.0) // * Install GlassFish v3 Domain // * Install NetBeans IDE (preferably 6.0 + ), Web and Java EE // * Add Libraries: jaxb-impl.jar, jaxws-rt-2.0.jar, stax-impl. // jar,JAX-WS 2.1-activation.jar,etc depends on your run time requirements // Settings: // We can use a wizard to generate Java objects from the web service's WSDL file. // To generate Java objects, open net beans IDE then fallow these steps: // * Choose File > New Project (Ctrl-Shift-N). Under Categories, choose Java Application. // Under Projects, choose Java Application. Click Next. // * Name the project as Test and make sure that you specify an appropriate server // as your target server. Leave all other options at default and click Finish. // * In the Projects window, right-click the Test project node and choose New -> Other. // In the New File wizard choose Web Services-> Web Service Client. In the Web Service // Client wizard, specify the URL to the web service: // http://www.cbs.dtu.dk/ws/RNAmmer/RNAmmer_1_2_ws1.wsdl // * If you are behind a firewall, you might need to specify a proxy server-otherwise // the WSDL file cannot be downloaded. To specify the proxy server, click Set Proxy // in the wizard. The IDE's Options window opens, where you can set the proxy universally // for the IDE. // * Leave the package name blank. By default the client class package name is taken from // the WSDL. In this case is WSRNAmmer_1_2_ws1.Select JAX version JAX-WS. Click Finish. // * In the Projects window, within the Web Service References node, you see our service // reference files. // * Add appropriate libraries/jar files. // * Once the java objects created then we can start to use generated Java objects. // * In the main java class page, copy above client code and paste it. // Access Web service: // Ths RNAmmer service code access to see one method results at once. If you would like to // see runService method results then you would need to comment the rest of the methods code // and for rest also same. In the runService you need to submit required fileds like one id // and corresponding sequence or more ids and their corresponding sequences as a input(STDIN) // data to convert FASTA format to get the results. // For input data/FASTA format see example: // http://www.cbs.dtu.dk/ws/RNAmmer/examples/example) // After getting jobid from runService then you would need to submit jobid in the pollQueue // to know the status of the job. After knowing the status of the job from pollQueue then // you need to submit jobid in the fetchResult to see complete final results. // It means you can only see final results in the fetchResult since RNAmmer is implemented // in asynchronous way // Run: // * After saving above code in the main class. Right click and (down on the menu) click on run // as java application or in the menu bar->run->run File. // * Now We can see SOAP envelope request/Response..