You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2005/02/15 09:19:23 UTC

svn commit: r153910 - in webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1: ./ conf/ conf/META-INF/ src/samples/userguide/sample1/client/ src/samples/userguide/sample1/server/

Author: chathura
Date: Tue Feb 15 00:19:19 2005
New Revision: 153910

URL: http://svn.apache.org/viewcvs?view=rev&rev=153910
Log:
Sample 1 Completed with Hot deployment

Added:
    webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/build.xml
    webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/conf/
    webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/conf/META-INF/
    webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/conf/META-INF/service.xml
Modified:
    webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/EchoInt.java
    webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/EchoString.java
    webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/InteropTest_Stub.java
    webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/server/SampleEnvironmentCreator.java

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/build.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/build.xml?view=auto&rev=153910
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/build.xml (added)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/build.xml Tue Feb 15 00:19:19 2005
@@ -0,0 +1,109 @@
+<?xml version="1.0"?>
+<!-- ====================================================================== 
+     Feb 11, 2005 1:04:21 PM                                                        
+
+      This build file is intended to compile and run the Axis2 sample
+      provided here with the service being deployed at Tomcat or by
+      running a simple Axis2 server.   
+     
+                   
+     Chathura                                                                
+     ====================================================================== -->
+<project name="sample1" basedir="." default="jar">
+	<property name="src.dir" value="src" />
+	<property name="classes.dir" value="./classes" />
+	<property name="build.dir" value="./build" />
+	<property name="lib.dir" value="./lib" />
+	<property name="conf.dir" value="./conf"/>
+	<property name="jardrop.dir" value="services"/>
+	<property name="server.jardrop.relative.dir" value="webapps/axis2/WEB-INF/services"/>
+	<property environment="env"/>
+	
+	
+	
+	
+	<path id="classpath.library">
+        <fileset dir="${lib.dir}">
+            <include name="**/*.jar"/>            
+        </fileset>
+    </path>
+	
+	<path id="classpath.classes">
+		<pathelement location="${classes.dir}"/>
+	</path>
+	
+	<path id="classpath.runtimelibraries">
+		<pathelement path="classpath.classes"/>
+	</path>
+	
+
+	
+
+	<target name="clean" description="Delete all generated files">
+		<delete dir="${classes.dir}" />
+		<delete dir="${services.dir}" failonerror="false"/>
+		<delete dir="${build.dir}" />
+	</target>
+
+	<target name="validateTomcatHome">
+		<available file="${env.CATALINA_HOME}/webapps/axis2" type="dir" property="axis2.deployed"/>				
+	</target>
+	
+	<target name="validateSevices.dir">
+		<available  file="${env.CATALINA_HOME}/webapps/axis2/WEB-INF/services" type="dir" property="axis2.services"/>	
+	</target>
+	
+	<target name="validateDeploymentSettings" depends="validateTomcatHome" unless="validateSevices.dir">
+		<mkdir dir="${env.CATALINA_HOME}/webapps/axis2/WEB-INF/services"/>
+	</target>
+	
+
+	<target name="createDir">
+		<mkdir dir="${build.dir}" />
+		<mkdir dir="${classes.dir}" />
+		<mkdir dir="${build.dir}/${jardrop.dir}"/>
+	</target>
+
+	<target name="compile" depends="createDir">
+		<javac srcdir="${src.dir}" destdir="${classes.dir}" >
+			<classpath refid="classpath.library"/>
+		</javac>
+	</target>
+
+	<target name="jar" depends="clean,compile">
+		<jar destfile="${build.dir}/${jardrop.dir}/${ant.project.name}.jar">	
+			
+			<fileset dir="${classes.dir}"> 
+				<include name="**/EchoImpl.class"/>				
+			</fileset>
+			<fileset dir="${conf.dir}">
+				<include name="META-INF/service.xml"/>
+			</fileset>
+		</jar>
+		<jar destfile="${lib.dir}/${ant.project.name}-all.jar">
+			<fileset dir="${classes.dir}"/> 
+		</jar>
+	</target>
+	
+	<target name="deploy" depends="jar,validateDeploymentSettings">
+		<copy file="${build.dir}/${jardrop.dir}/${ant.project.name}.jar" todir="${env.CATALINA_HOME}/${server.jardrop.relative.dir}" overwrite="true"/>			
+	</target>
+	
+	<target name="echoString" depends="compile">
+		<java classname="samples.userguide.sample1.client.EchoString">
+			<classpath refid="classpath.library"/>
+			<arg value="8080"/>
+			<arg value="Hi Axis2 this is to test the EchoString(to change the string look in the build file)"/>
+		</java>
+	</target>
+	
+	<target name="echoInt" depends="compile">
+			<java classname="samples.userguide.sample1.client.EchoInt">
+				<classpath refid="classpath.library"/>
+				<arg value="8080"/>
+				<arg value="329"/>
+			</java>
+		</target>
+	
+</project>
+

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/conf/META-INF/service.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/conf/META-INF/service.xml?view=auto&rev=153910
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/conf/META-INF/service.xml (added)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/conf/META-INF/service.xml Tue Feb 15 00:19:19 2005
@@ -0,0 +1,28 @@
+<service provider="org.apache.axis.testUtils.SimpleJavaProvider" style="xsd:anyURI" contextPath="xsd:anycontextPath" >
+    <java:implementation class="samples.userguide.sample1.server.EchoImpl" xmlns:java="http://ws.apache.org/axis2/deployment/java"/>
+
+    <!-- these are Service Parameters -->
+    <!--
+    <parameter name="para1" locked="xsd:true">10</parameter>
+    <parameter name="para2" locked="xsd:false">Colombo</parameter>
+
+    <module ref="module1"></module>
+    <module ref="module2"></module>
+-->
+
+    <!--  Service TypeMapping -->
+
+
+
+    <!--
+    Phases
+    P1 p2 p3
+    -->
+
+    
+
+
+    <operation name="echoInt" qname="http://localhost/my:echoInt"/>
+    <operation name="echoString" qname="http://localhost/my:echoString"/>
+    
+</service>
\ No newline at end of file

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/EchoInt.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/EchoInt.java?view=diff&r1=153909&r2=153910
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/EchoInt.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/EchoInt.java Tue Feb 15 00:19:19 2005
@@ -19,7 +19,6 @@
 
 import org.apache.axis.addressing.AddressingConstants;
 import org.apache.axis.addressing.EndpointReference;
-import org.apache.axis.engine.EngineUtils;
 
 /**
  * @author chathura@opensource.lk
@@ -28,10 +27,14 @@
 public class EchoInt {
 	
 	public static void main(String[] args) throws Exception {
+		if(2!= args.length ){
+			System.out.println("Usage <Port> <Echo Message>");
+			
+		}
 		InteropTest_Stub clientStub = new InteropTest_Stub();
-		URL url = new URL("http","127.0.0.1",EngineUtils.TESTING_PORT,"/axis2/services/sample1");
+		URL url = new URL("http","127.0.0.1",new Integer(args[0]).intValue(),"/axis2/services/sample1");
 		clientStub.setEndPointReference(new EndpointReference(AddressingConstants.WSA_TO, url.toString()));
-		Integer echoInt = clientStub.echoInt(new Integer(794));
+		Integer echoInt = clientStub.echoInt(new Integer(args[1]));
 		System.out.println(echoInt);
 		
 	}

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/EchoString.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/EchoString.java?view=diff&r1=153909&r2=153910
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/EchoString.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/EchoString.java Tue Feb 15 00:19:19 2005
@@ -19,7 +19,6 @@
 
 import org.apache.axis.addressing.AddressingConstants;
 import org.apache.axis.addressing.EndpointReference;
-import org.apache.axis.engine.EngineUtils;
 
 /**
  * @author chathura@opensource.lk
@@ -29,9 +28,9 @@
 
 	public static void main(String[] args) throws Exception{
 		InteropTest_Stub stub =new InteropTest_Stub();
-		URL url = new URL("http","127.0.0.1",EngineUtils.TESTING_PORT,"/axis/services/sample1");
+		URL url = new URL("http","127.0.0.1", new Integer(args[0]).intValue(),"/axis2/services/sample1");
 		stub.setEndPointReference(new EndpointReference(AddressingConstants.WSA_TO, url.toString()));
-		System.out.println(stub.echoString("Hi Chinthaka"));
+		System.out.println(stub.echoString(args[1]));
 		
 		
 	}

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/InteropTest_Stub.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/InteropTest_Stub.java?view=diff&r1=153909&r2=153910
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/InteropTest_Stub.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/client/InteropTest_Stub.java Tue Feb 15 00:19:19 2005
@@ -104,6 +104,9 @@
 		Iterator childrenIter = body.getChildren();
 		while(childrenIter.hasNext()){
 			OMNode child = (OMNode) childrenIter.next();
+			if(child instanceof OMElement && "Fault".equalsIgnoreCase(((OMElement)child).getLocalName())){
+				throw new AxisFault("Fault in server side");
+			}
 			if(child instanceof OMElement && "echoStringResponse".equalsIgnoreCase(((OMElement)child).getLocalName())){
 				response = (OMElement)child;				
 			}
@@ -130,6 +133,9 @@
 		Iterator childrenIter = body.getChildren();
 		while(childrenIter.hasNext()){
 			OMNode child = (OMNode) childrenIter.next();
+			if(child instanceof OMElement && "Fault".equalsIgnoreCase(((OMElement)child).getLocalName())){
+				throw new AxisFault("Fault in server side");
+			}
 			if(child instanceof OMElement && "echoIntResponse".equalsIgnoreCase(((OMElement)child).getLocalName())){
 				response = (OMElement)child;				
 			}

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/server/SampleEnvironmentCreator.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/server/SampleEnvironmentCreator.java?view=diff&r1=153909&r2=153910
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/server/SampleEnvironmentCreator.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/userguide/sample1/src/samples/userguide/sample1/server/SampleEnvironmentCreator.java Tue Feb 15 00:19:19 2005
@@ -15,17 +15,8 @@
  */
 package samples.userguide.sample1.server;
 
-import java.io.FileReader;
-import java.net.URL;
-
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
 
-import org.apache.axis.AbstractTestCase;
-import org.apache.axis.addressing.AddressingConstants;
-import org.apache.axis.addressing.EndpointReference;
-import org.apache.axis.clientapi.Call;
 import org.apache.axis.context.MessageContext;
 import org.apache.axis.description.AxisGlobal;
 import org.apache.axis.description.AxisOperation;
@@ -34,8 +25,6 @@
 import org.apache.axis.engine.EngineRegistry;
 import org.apache.axis.engine.EngineRegistryImpl;
 import org.apache.axis.engine.EngineUtils;
-import org.apache.axis.om.SOAPEnvelope;
-import org.apache.axis.om.impl.llom.builder.StAXSOAPModelBuilder;
 import org.apache.axis.testUtils.SimpleJavaProvider;
 import org.apache.axis.transport.http.SimpleHTTPReceiver;
 import org.apache.commons.logging.Log;
@@ -45,7 +34,7 @@
  * @author chathura@opensource.lk
  * 
  */
-public class SampleEnvironmentCreator extends  AbstractTestCase{
+public class SampleEnvironmentCreator {
 	
     private Log log = LogFactory.getLog(getClass());
     private QName serviceName = new QName("","sample1");
@@ -59,21 +48,8 @@
     private SimpleHTTPReceiver sas;
     
     public SampleEnvironmentCreator(){
-        super(SampleEnvironmentCreator.class.getName());
-//        try {
-//			this.setUp();
-//			this.testInt();
-//			this.tearDown();
-//		} catch (Exception e) {
-//			// TODO Auto-generated catch block
-//			e.printStackTrace();
-//		}
         
     }
-
-    public SampleEnvironmentCreator(String testName) {
-        super(testName);
-    }
     
     public void setUp() throws Exception {
         AxisGlobal global = new AxisGlobal();
@@ -103,69 +79,7 @@
 }
 
 
-public void testInt() throws Exception{
-    try{
-   
-        Call call = new Call();
-        URL url = new URL("http","127.0.0.1",EngineUtils.TESTING_PORT,"/axis/services/EchoXMLService");
-        EndpointReference epr = new EndpointReference(AddressingConstants.WSA_TO, url.toString());
-        call.setTo(epr);
-        SOAPEnvelope reply = call.sendReceive(this.getechoIntEnvelope());
-        reply.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out), false);
-        
-    }catch(Exception e){
-        e.printStackTrace();
-        tearDown();
-        throw e;
-    }    
-}
-public void testString() throws Exception{
-//    try{
-//        OMFactory fac = OMFactory.newInstance();
-//
-//        OMNamespace omNs = fac.createOMNamespace("http://localhost/my","my");
-//        OMElement method =  fac.createOMElement("echoOMElement",omNs) ;
-//        OMElement value =  fac.createOMElement("myValue",omNs) ;
-//        value.setValue("Isaac Assimov, the foundation Sega");
-//        method.addChild(value);
-//        
-//        Call call = new Call();
-//        URL url = new URL("http","127.0.0.1",EngineUtils.TESTING_PORT,"/axis/services/EchoXMLService");
-//        
-//        CallBack callback = new CallBack() {
-//            public void doWork(OMElement ele) {
-//                System.out.print("got the result = " + ele +" :)");
-//
-//            }
-//            public void reportError(Exception e) {
-//                log.info("reporting error from callback !");
-//                e.printStackTrace();
-//            }
-//        };
-//        
-//        call.asyncCall(method,url,callback);
-//        log.info("send the reqest");
-//        
-//        Thread.sleep(1000);
-//    }catch(Exception e){
-//        e.printStackTrace();
-//        tearDown();
-//        throw e;
-//    }    
-}
 
- public static void main(String[] args) {
- 	new SampleEnvironmentCreator();
-	
-}
-
-private SOAPEnvelope getechoIntEnvelope() throws Exception {
-
-    SOAPEnvelope envelope = new StAXSOAPModelBuilder(XMLInputFactory.newInstance().createXMLStreamReader(
-            new FileReader(getTestResourceFile("echo/echoInt.xml")))).getSOAPEnvelope();
-    envelope.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out), false);
-    return envelope;
-}
 	
     
 }