From 59d2a68840c0c7905419304095d91faa5ef3004c Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Fri, 31 Jan 2014 14:30:32 +0000 Subject: [PATCH] First working web service for quering proteocache DB --- WEB-INF/sun-jaxws.xml | 4 +- WEB-INF/web.xml | 5 +- server/compbio/ws/jpred/Jpred.java | 9 ++- server/compbio/ws/jpred/JpredClient.java | 15 ++-- server/compbio/ws/jpred/JpredWS.java | 22 +++--- server/compbio/ws/jpred/WSPublisher.java | 12 --- server/compbio/ws/jpred/jaxws/FindSequence.java | 78 ++++++++++++++++++++ .../ws/jpred/jaxws/FindSequenceResponse.java | 4 +- server/compbio/ws/resources/ProteoCacheWS.wsdl | 39 ++++++++++ .../compbio/ws/resources/ProteoCacheWS_schema1.xsd | 22 ++++++ webapp/compbio/ws/jpred/jaxws/FindSequence.java | 36 --------- wsbuild.xml | 8 +- 12 files changed, 175 insertions(+), 79 deletions(-) delete mode 100644 server/compbio/ws/jpred/WSPublisher.java create mode 100644 server/compbio/ws/jpred/jaxws/FindSequence.java rename {webapp => server}/compbio/ws/jpred/jaxws/FindSequenceResponse.java (94%) create mode 100644 server/compbio/ws/resources/ProteoCacheWS.wsdl create mode 100644 server/compbio/ws/resources/ProteoCacheWS_schema1.xsd delete mode 100644 webapp/compbio/ws/jpred/jaxws/FindSequence.java diff --git a/WEB-INF/sun-jaxws.xml b/WEB-INF/sun-jaxws.xml index 7cc435f..c6b4285 100644 --- a/WEB-INF/sun-jaxws.xml +++ b/WEB-INF/sun-jaxws.xml @@ -1,6 +1,6 @@ + implementation='compbio.ws.jpred.JpredWS' + url-pattern='/ProteoCacheWS'/> diff --git a/WEB-INF/web.xml b/WEB-INF/web.xml index f084afd..0808c19 100644 --- a/WEB-INF/web.xml +++ b/WEB-INF/web.xml @@ -20,7 +20,10 @@ org.springframework.web.context.ContextLoaderListener - + + com.sun.xml.ws.transport.http.servlet.WSServletContextListener + + contextConfigLocation diff --git a/server/compbio/ws/jpred/Jpred.java b/server/compbio/ws/jpred/Jpred.java index 7d72d64..cebac29 100644 --- a/server/compbio/ws/jpred/Jpred.java +++ b/server/compbio/ws/jpred/Jpred.java @@ -1,11 +1,12 @@ package compbio.ws.jpred; +import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; -@WebService(targetNamespace = "http://server.ws.compbio") +@WebService(targetNamespace = "http://server.proteocache.ws") public interface Jpred { - - public String findSequence(@WebParam(name = "sequence") String sequence); - + @WebMethod + public String findSequence(@WebParam(name = "sequence") String sequence, @WebParam(name = "program") String program, + @WebParam(name = "version") String version); } diff --git a/server/compbio/ws/jpred/JpredClient.java b/server/compbio/ws/jpred/JpredClient.java index 40cbdd6..d5a91d7 100644 --- a/server/compbio/ws/jpred/JpredClient.java +++ b/server/compbio/ws/jpred/JpredClient.java @@ -1,26 +1,23 @@ package compbio.ws.jpred; -import java.util.Properties; - import javax.xml.ws.Service; import javax.xml.namespace.QName; import java.net.URL; /** - * This class was generated by Apache CXF 2.7.8 2013-12-09T11:22:58.858Z - * Generated source version: 2.7.8 * */ public class JpredClient { public static void main(String[] args) throws Exception { - Properties properties = new Properties(); - properties.setProperty("openejb.embedded.remotable", "true"); - QName qname = new QName("http://server.ws.compbio", "JpredWS"); - Service service = Service.create(new URL("http://localhost:1236/proteocache/services"), qname); + QName qname = new QName("http://server.proteocache.ws", "ProteoCacheWS"); + + Service service = Service.create(new URL("http://localhost:8080/proteocache-1.0/ProteoCacheWS"), qname); Jpred sequense = service.getPort(Jpred.class); - System.out.println(" : " + sequense.findSequence("MDVQAAPALMLCSATPALRRHGGMTGPVRLSGDIRC")); + String result= sequense.findSequence("EQCGRQAGGKLCPNNLCCSQWGWCGSTDEYCS", "Jpred", "3.0.1"); + + System.out.println("Result : " + result); } } diff --git a/server/compbio/ws/jpred/JpredWS.java b/server/compbio/ws/jpred/JpredWS.java index 2f208ad..77d40da 100644 --- a/server/compbio/ws/jpred/JpredWS.java +++ b/server/compbio/ws/jpred/JpredWS.java @@ -2,21 +2,25 @@ package compbio.ws.jpred; import javax.jws.WebService; +import org.apache.log4j.Logger; + import compbio.cassandra.CassandraNativeConnector; -import compbio.statistic.CassandraRequester; +import compbio.cassandra.readers.SequenceReader; -@WebService(endpointInterface = "compbio.ws.jpred.Jpred", targetNamespace = "http://server.ws.compbio", serviceName = "JpredWS") +@WebService(endpointInterface = "compbio.ws.jpred.Jpred", targetNamespace = "http://server.proteocache.ws", serviceName = "ProteoCacheWS", portName = "ProteoCacheWSPort") public class JpredWS implements Jpred { + private static Logger log = Logger.getLogger(CassandraNativeConnector.class); @Override - public String findSequence(String sequence) { + public String findSequence(String sequence, String program, String version) { CassandraNativeConnector dbconnector = new CassandraNativeConnector(); - CassandraRequester cr = new CassandraRequester(); - System.out.println("YES"); - if (cr.readProteins(sequence, "whole") != null) - return "The sequence is " + sequence; - else - return "No sequence " + sequence; + SequenceReader reader = new SequenceReader(); + reader.setSession(dbconnector.getSession()); + log.debug("ProteoCacheWS is connected:\n search for sequence: " + sequence + "\ncalculated wih " + program + " (version; " + version + ")"); + if (null != reader.readProteins(sequence, "whole")) { + return "The sequence " + sequence + " found. Calculated with " + program + "(" + version + ")"; + } + return "The sequence " + sequence + " not found"; } } diff --git a/server/compbio/ws/jpred/WSPublisher.java b/server/compbio/ws/jpred/WSPublisher.java deleted file mode 100644 index 01747e0..0000000 --- a/server/compbio/ws/jpred/WSPublisher.java +++ /dev/null @@ -1,12 +0,0 @@ -package compbio.ws.jpred; - -import javax.xml.ws.Endpoint; - -public class WSPublisher { - - public static void main(String[] args) { - Endpoint.publish("http://localhost:1236/proteocache/services", new JpredWS()); - - System.out.println("Service is published!"); - } -} diff --git a/server/compbio/ws/jpred/jaxws/FindSequence.java b/server/compbio/ws/jpred/jaxws/FindSequence.java new file mode 100644 index 0000000..d1b23d2 --- /dev/null +++ b/server/compbio/ws/jpred/jaxws/FindSequence.java @@ -0,0 +1,78 @@ +package compbio.ws.jpred.jaxws; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlRootElement(name = "findSequence", namespace = "http://server.proteocache.ws") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "findSequence", namespace = "http://server.proteocache.ws", propOrder = { "sequence", "program", "version" }) +public class FindSequence { + + @XmlElement(name = "sequence", namespace = "") + private String sequence; + @XmlElement(name = "program", namespace = "") + private String program; + @XmlElement(name = "version", namespace = "") + private String version; + + /** + * + * @return returns String + */ + public String getSequence() { + System.out.println("FindSequence.setSequence: output sequence " + this.sequence); + return this.sequence; + } + + /** + * + * @param sequence + * the value for the sequence property + */ + public void setSequence(String sequence) { + System.out.println("FindSequence.setSequence: input sequence " + sequence); + this.sequence = sequence; + } + + /** + * + * @return returns String + */ + public String getProgram() { + System.out.println("FindSequence.setProgram: output program " + this.program); + return this.program; + } + + /** + * + * @param program + * the value for the program property + */ + public void setProgram(String program) { + System.out.println("FindSequence.setProgram: input program " + program); + this.program = program; + } + + /** + * + * @return returns String + */ + public String getVersion() { + System.out.println("FindSequence.setVersion: output version " + this.version); + return this.version; + } + + /** + * + * @param version + * the value for the version property + */ + public void setVersion(String version) { + System.out.println("FindSequence.setVersion: input version " + version); + this.version = version; + } + +} diff --git a/webapp/compbio/ws/jpred/jaxws/FindSequenceResponse.java b/server/compbio/ws/jpred/jaxws/FindSequenceResponse.java similarity index 94% rename from webapp/compbio/ws/jpred/jaxws/FindSequenceResponse.java rename to server/compbio/ws/jpred/jaxws/FindSequenceResponse.java index b53fb20..7889071 100644 --- a/webapp/compbio/ws/jpred/jaxws/FindSequenceResponse.java +++ b/server/compbio/ws/jpred/jaxws/FindSequenceResponse.java @@ -7,9 +7,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -@XmlRootElement(name = "findSequenceResponse", namespace = "http://server.ws.compbio") +@XmlRootElement(name = "findSequenceResponse", namespace = "http://server.proteocache.ws") @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "findSequenceResponse", namespace = "http://server.ws.compbio") +@XmlType(name = "findSequenceResponse", namespace = "http://server.proteocache.ws") public class FindSequenceResponse { @XmlElement(name = "return", namespace = "") diff --git a/server/compbio/ws/resources/ProteoCacheWS.wsdl b/server/compbio/ws/resources/ProteoCacheWS.wsdl new file mode 100644 index 0000000..c456e47 --- /dev/null +++ b/server/compbio/ws/resources/ProteoCacheWS.wsdl @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/compbio/ws/resources/ProteoCacheWS_schema1.xsd b/server/compbio/ws/resources/ProteoCacheWS_schema1.xsd new file mode 100644 index 0000000..d9ee154 --- /dev/null +++ b/server/compbio/ws/resources/ProteoCacheWS_schema1.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp/compbio/ws/jpred/jaxws/FindSequence.java b/webapp/compbio/ws/jpred/jaxws/FindSequence.java deleted file mode 100644 index 978ffeb..0000000 --- a/webapp/compbio/ws/jpred/jaxws/FindSequence.java +++ /dev/null @@ -1,36 +0,0 @@ - -package compbio.ws.jpred.jaxws; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlRootElement(name = "findSequence", namespace = "http://server.ws.compbio") -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "findSequence", namespace = "http://server.ws.compbio") -public class FindSequence { - - @XmlElement(name = "sequence", namespace = "") - private String sequence; - - /** - * - * @return - * returns String - */ - public String getSequence() { - return this.sequence; - } - - /** - * - * @param sequence - * the value for the sequence property - */ - public void setSequence(String sequence) { - this.sequence = sequence; - } - -} diff --git a/wsbuild.xml b/wsbuild.xml index 17b4995..0f5037d 100644 --- a/wsbuild.xml +++ b/wsbuild.xml @@ -17,8 +17,8 @@ - - + + @@ -26,7 +26,7 @@ - + @@ -42,7 +42,7 @@