First working web service for quering proteocache DB PROT-9-webservice
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 31 Jan 2014 14:30:32 +0000 (14:30 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 31 Jan 2014 14:30:32 +0000 (14:30 +0000)
12 files changed:
WEB-INF/sun-jaxws.xml
WEB-INF/web.xml
server/compbio/ws/jpred/Jpred.java
server/compbio/ws/jpred/JpredClient.java
server/compbio/ws/jpred/JpredWS.java
server/compbio/ws/jpred/WSPublisher.java [deleted file]
server/compbio/ws/jpred/jaxws/FindSequence.java [new file with mode: 0644]
server/compbio/ws/jpred/jaxws/FindSequenceResponse.java [moved from webapp/compbio/ws/jpred/jaxws/FindSequenceResponse.java with 94% similarity]
server/compbio/ws/resources/ProteoCacheWS.wsdl [new file with mode: 0644]
server/compbio/ws/resources/ProteoCacheWS_schema1.xsd [new file with mode: 0644]
webapp/compbio/ws/jpred/jaxws/FindSequence.java [deleted file]
wsbuild.xml

index 7cc435f..c6b4285 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>\r
        <endpoint name='JpredWS'\r
 <?xml version="1.0" encoding="UTF-8"?>\r
 <endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>\r
        <endpoint name='JpredWS'\r
-               implementation='compbio.ws.jpred.Jpred'\r
-               url-pattern='/JpredWS'/>\r
+               implementation='compbio.ws.jpred.JpredWS'\r
+               url-pattern='/ProteoCacheWS'/>\r
 </endpoints>\r
 </endpoints>\r
index f084afd..0808c19 100644 (file)
        <listener>\r
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\r
        </listener>\r
        <listener>\r
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\r
        </listener>\r
-\r
+       <listener>\r
+               <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>\r
+       </listener>\r
+       \r
        <context-param>\r
                <param-name>contextConfigLocation</param-name>\r
                <param-value>\r
        <context-param>\r
                <param-name>contextConfigLocation</param-name>\r
                <param-value>\r
index 7d72d64..cebac29 100644 (file)
@@ -1,11 +1,12 @@
 package compbio.ws.jpred;
 
 package compbio.ws.jpred;
 
+import javax.jws.WebMethod;
 import javax.jws.WebParam;
 import javax.jws.WebService;
 
 import javax.jws.WebParam;
 import javax.jws.WebService;
 
-@WebService(targetNamespace = "http://server.ws.compbio")
+@WebService(targetNamespace = "http://server.proteocache.ws")
 public interface Jpred {
 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);
 }
 }
index 40cbdd6..d5a91d7 100644 (file)
@@ -1,26 +1,23 @@
 package compbio.ws.jpred;
 
 package compbio.ws.jpred;
 
-import java.util.Properties;
-
 import javax.xml.ws.Service;
 import javax.xml.namespace.QName;
 
 import java.net.URL;
 
 /**
 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 {
  * 
  */
 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);
                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);
        }
 
 }
        }
 
 }
index 2f208ad..77d40da 100644 (file)
@@ -2,21 +2,25 @@ package compbio.ws.jpred;
 
 import javax.jws.WebService;
 
 
 import javax.jws.WebService;
 
+import org.apache.log4j.Logger;
+
 import compbio.cassandra.CassandraNativeConnector;
 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 {
 public class JpredWS implements Jpred {
+       private static Logger log = Logger.getLogger(CassandraNativeConnector.class);
 
        @Override
 
        @Override
-       public String findSequence(String sequence) {
+       public String findSequence(String sequence, String program, String version) {
                CassandraNativeConnector dbconnector = new CassandraNativeConnector();
                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 (file)
index 01747e0..0000000
+++ /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 (file)
index 0000000..d1b23d2
--- /dev/null
@@ -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;
+       }
+
+}
@@ -7,9 +7,9 @@ import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
 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)
 @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 = "")
 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 (file)
index 0000000..c456e47
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.1 (branches/2.1-6728; 2011-02-03T14:14:58+0000) JAXWS-RI/2.2.3 JAXWS/2.2. -->
+<definitions targetNamespace="http://server.proteocache.ws" name="ProteoCacheWS" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://server.proteocache.ws" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
+  <types>
+    <xsd:schema>
+      <xsd:import namespace="http://server.proteocache.ws" schemaLocation="ProteoCacheWS_schema1.xsd"/>
+    </xsd:schema>
+  </types>
+  <message name="findSequence">
+    <part name="parameters" element="tns:findSequence"/>
+  </message>
+  <message name="findSequenceResponse">
+    <part name="parameters" element="tns:findSequenceResponse"/>
+  </message>
+  <portType name="Jpred">
+    <operation name="findSequence">
+      <input wsam:Action="http://server.proteocache.ws/Jpred/findSequenceRequest" message="tns:findSequence"/>
+      <output wsam:Action="http://server.proteocache.ws/Jpred/findSequenceResponse" message="tns:findSequenceResponse"/>
+    </operation>
+  </portType>
+  <binding name="ProteoCacheWSPortBinding" type="tns:Jpred">
+    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+    <operation name="findSequence">
+      <soap:operation soapAction=""/>
+      <input>
+        <soap:body use="literal"/>
+      </input>
+      <output>
+        <soap:body use="literal"/>
+      </output>
+    </operation>
+  </binding>
+  <service name="ProteoCacheWS">
+    <port name="ProteoCacheWSPort" binding="tns:ProteoCacheWSPortBinding">
+      <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+    </port>
+  </service>
+</definitions>
+
diff --git a/server/compbio/ws/resources/ProteoCacheWS_schema1.xsd b/server/compbio/ws/resources/ProteoCacheWS_schema1.xsd
new file mode 100644 (file)
index 0000000..d9ee154
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://server.proteocache.ws" xmlns:tns="http://server.proteocache.ws" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+  <xs:element name="findSequence" type="tns:findSequence"/>
+
+  <xs:element name="findSequenceResponse" type="tns:findSequenceResponse"/>
+
+  <xs:complexType name="findSequence">
+    <xs:sequence>
+      <xs:element name="sequence" type="xs:string" minOccurs="0"/>
+      <xs:element name="program" type="xs:string" minOccurs="0"/>
+      <xs:element name="version" type="xs:string" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="findSequenceResponse">
+    <xs:sequence>
+      <xs:element name="return" type="xs:string" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
+
diff --git a/webapp/compbio/ws/jpred/jaxws/FindSequence.java b/webapp/compbio/ws/jpred/jaxws/FindSequence.java
deleted file mode 100644 (file)
index 978ffeb..0000000
+++ /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;
-    }
-
-}
index 17b4995..0f5037d 100644 (file)
@@ -17,8 +17,8 @@
                        </fileset>
                </path>
 
                        </fileset>
                </path>
 
-               <property name="wsdl.dir" location="${basedir}/webapp/resources" />
-               <property name="jpred.wsdl" location="${wsdl.dir}/JpredWS.wsdl" />
+               <property name="wsdl.dir" location="${basedir}/server/compbio/ws/resources" />
+               <property name="jpred.wsdl" location="${wsdl.dir}/ProteoCacheWS.wsdl" />
 
                <taskdef name="wsgen" onerror="report" classname="com.sun.tools.ws.ant.WsGen">
                        <classpath refid="project.classpath" />
 
                <taskdef name="wsgen" onerror="report" classname="com.sun.tools.ws.ant.WsGen">
                        <classpath refid="project.classpath" />
@@ -26,7 +26,7 @@
 
                <target name="main">
                        <!-- TODO this runs file from Eclipse, but with Ant only this need to depends on clean and build! -->
 
                <target name="main">
                        <!-- TODO this runs file from Eclipse, but with Ant only this need to depends on clean and build! -->
-                       <property name="server.artifacts.dir" location="${basedir}/webapp/compbio/ws/jpred/jaxws/" />
+                       <property name="server.artifacts.dir" location="${basedir}/server/compbio/ws/jpred/jaxws/" />
 
                        <mkdir dir="${server.artifacts.dir}" />
                        <mkdir dir="${wsdl.dir}" />
 
                        <mkdir dir="${server.artifacts.dir}" />
                        <mkdir dir="${wsdl.dir}" />
@@ -42,7 +42,7 @@
                        <!-- sourcedestdir -  Where to put generated source files -->
                        <!-- resourcedestdir - Where to put generated source files -->
                        <wsgen sei="compbio.ws.jpred.JpredWS"
                        <!-- sourcedestdir -  Where to put generated source files -->
                        <!-- resourcedestdir - Where to put generated source files -->
                        <wsgen sei="compbio.ws.jpred.JpredWS"
-                                       sourcedestdir="${basedir}/webapp"
+                                       sourcedestdir="${basedir}/server"
                                        destdir="${classes}"
                                        resourcedestdir="${wsdl.dir}"
                                        keep="true"
                                        destdir="${classes}"
                                        resourcedestdir="${wsdl.dir}"
                                        keep="true"