You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ch...@apache.org on 2005/02/21 11:39:29 UTC
svn commit: r154665 - in webservices/axis/trunk/java/modules/samples: ./
conf/ src/java/userguide/sample1/
Author: chathura
Date: Mon Feb 21 02:39:27 2005
New Revision: 154665
URL: http://svn.apache.org/viewcvs?view=rev&rev=154665
Log:
Userguide sample done and complete with ant build. Along with the hot deployment.
Added:
webservices/axis/trunk/java/modules/samples/conf/
webservices/axis/trunk/java/modules/samples/conf/service.xml
webservices/axis/trunk/java/modules/samples/conf/service4withhandler.xml
webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/AsynchronousClient.java
webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/ClientEchoCallbackHandler.java
webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/ClientUtil.java
webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/LoggingHandler.java
Removed:
webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/service.xml
Modified:
webservices/axis/trunk/java/modules/samples/build.xml
webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/EchoXML.java
webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/SynchronousClient.java
Modified: webservices/axis/trunk/java/modules/samples/build.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/build.xml?view=diff&r1=154664&r2=154665
==============================================================================
--- webservices/axis/trunk/java/modules/samples/build.xml (original)
+++ webservices/axis/trunk/java/modules/samples/build.xml Mon Feb 21 02:39:27 2005
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0"?>
<!-- ======================================================================
Feb 11, 2005 1:04:21 PM
@@ -8,100 +8,132 @@
- ====================================================================== -->
-<project name="sample1" basedir="." default="compile">
- <property name="src.dir" value="src/java" />
- <property name="build.dir" value="${build.dir}/build" />
- <property name="lib.dir" value="${build.dir}/lib" />
- <property name="classes.dir" value="./classes" />
- <property name="setup.dir" value="${build.dir}/setup"/>
- <property name="jardrop.dir" value="${build.dir}/services"/>
- <property environment="env"/>
- <property name="AXIS_HOME" value="${env.AXIS_HOME}"/>
- <property name="axis.serverJarDrop.dir" value="${AXIS_HOME}/WEB-INF/services"/>
-
-
-
-
- <path id="classpath.library">
- <fileset dir="${AXIS_HOME}/WEB-INF/lib">
- <include name="**/*.jar"/>
- </fileset>
- </path>
-
- <path id="classpath.client">
- <fileset dir="${lib.dir}">
- <include name="**/*.jar"/>
- </fileset>
- </path>
-
- <path id="classpath.runtimelibraries">
- <path refid="classpath.library" />
- <path refid="classpath.client" />
- </path>
-
-
-
-
- <target name="clean" description="Delete all generated files">
- <delete dir="${classes.dir}" failonerror="false" />
- <delete dir="${services.dir}" failonerror="false"/>
- <delete dir="${build.dir}" failonerror="false" />
- <delete dir="${lib.dir}" failonerror="false"/>
- </target>
-
- <target name="validateAxisHome">
- <available file="${AXIS_HOME}}" type="dir" property="axis2.deployed"/>
- </target>
-
- <target name="validateSevices.dir">
- <available file="${AXIS_HOME}/WEB-INF/services" type="dir" property="axis2.services"/>
- </target>
-
- <target name="validateDeploymentSettings" depends="validateAxisHome" unless="validateSevices.dir">
- <mkdir dir="${AXIS_HOME}/WEB-INF/services"/>
- </target>
-
-
- <target name="createDir">
- <mkdir dir="${build.dir}" />
- <mkdir dir="${lib.dir}"/>
- <mkdir dir="${classes.dir}" />
- <mkdir dir="${build.dir}/${jardrop.dir}"/>
- </target>
-
- <target name="compile" depends="clean,createDir">
- <javac srcdir="${src.dir}" destdir="${classes.dir}" >
- <classpath refid="classpath.library"/>
- </javac>
- <jar destfile="${lib.dir}/${ant.project.name}-all.jar">
- <fileset dir="${classes.dir}"/>
- </jar>
-
- <mkdir dir="${setup.dir}/1"/>
- <copy todir="${setup.dir}/1">
- <fileset dir="${classes.dir}">
- <include name="**/EchoXML.class"/>
- </fileset>
- <fileset dir="${src.dir}">
- <include name="**/service.xml"/>
- </fileset>
- </copy>
-
- <jar destfile="${build.dir}/${jardrop.dir}/${ant.project.name}.jar" basedir="${setup.dir}/1"/>
- <delete dir="${classes.dir}" failonerror="false"/>
- </target>
-
-
- <target name="deploy" depends="compile,validateDeploymentSettings">
- <copy file="${build.dir}/${jardrop.dir}/${ant.project.name}.jar" todir="${axis.serverJarDrop.dir}" overwrite="true"/>
- </target>
-
- <target name="echo" depends="compile">
- <java classname="SynchronousClient">
- <classpath refid="classpath.runtimelibraries"/>
- <arg value="8080"/>
- </java>
- </target>
-</project>
-
+ ====================================================================== -->
+<project name="samples" basedir="." default="compile">
+ <property name="src.dir" value="src/java" />
+ <property name="build.dir" value="build" />
+ <property name="lib.dir" value="${build.dir}/lib" />
+ <property name="classes.dir" value="./classes" />
+
+ <property name="jardrop.dir" value="${build.dir}/services" />
+ <property environment="env" />
+ <property name="AXIS_HOME" value="${env.AXIS_HOME}" />
+ <property name="axis.serverJarDrop.dir" value="${AXIS_HOME}/WEB-INF/services" />
+
+
+
+ <property name="conf.dir" value="conf"/>
+
+ <path id="classpath.library">
+ <fileset dir="${AXIS_HOME}/WEB-INF/lib">
+ <include name="**/*.jar" />
+ </fileset>
+ </path>
+
+ <path id="classpath.client">
+ <fileset dir="${lib.dir}">
+ <include name="**/*.jar" />
+ </fileset>
+ </path>
+
+ <path id="classpath.runtimelibraries">
+ <path refid="classpath.library" />
+ <path refid="classpath.client" />
+ </path>
+
+
+
+
+ <target name="clean" description="Delete all generated files">
+ <delete dir="${classes.dir}" failonerror="false" />
+
+ <delete dir="${build.dir}" failonerror="false" />
+ </target>
+
+ <target name="validateAxisHome">
+ <available file="${AXIS_HOME}}" type="dir" property="axis2.deployed" />
+ </target>
+
+ <target name="validateSevices.dir">
+ <available file="${AXIS_HOME}/WEB-INF/services" type="dir" property="axis2.services" />
+ </target>
+
+ <target name="validateDeploymentSettings" depends="validateAxisHome" unless="validateSevices.dir">
+ <mkdir dir="${AXIS_HOME}/WEB-INF/services" />
+ </target>
+
+
+ <target name="createDir">
+ <mkdir dir="${build.dir}" />
+ <mkdir dir="${lib.dir}" />
+ <mkdir dir="${classes.dir}" />
+ <mkdir dir="${jardrop.dir}" />
+ </target>
+
+ <target name="compile" depends="clean,createDir">
+ <javac srcdir="${src.dir}" destdir="${classes.dir}">
+ <classpath refid="classpath.library" />
+ </javac>
+ <jar destfile="${lib.dir}/${ant.project.name}-all.jar">
+ <fileset dir="${classes.dir}" />
+ </jar>
+
+ <copy file="${conf.dir}/service.xml" todir="${build.dir}/META-INF" overwrite="true" />
+
+ <jar destfile="${jardrop.dir}/sample1.jar">
+
+ <fileset dir="${classes.dir}">
+ <include name="**/EchoXML.class" />
+ </fileset>
+ <fileset dir="${build.dir}">
+ <include name="META-INF/service.xml" />
+ </fileset>
+ </jar>
+
+
+ <copy file="${conf.dir}/service4withhandler.xml" tofile="${build.dir}/META-INF/service.xml" overwrite="true" />
+
+ <jar destfile="${jardrop.dir}/sample1WithHandler.jar">
+
+ <fileset dir="${classes.dir}">
+ <include name="**/EchoXML.class" />
+ <include name="**/LoggingHandler.class" />
+ </fileset>
+ <fileset dir="${build.dir}">
+ <include name="META-INF/service.xml" />
+ </fileset>
+ </jar>
+ <delete dir="${classes.dir}" failonerror="false" />
+ </target>
+
+
+ <target name="deploy" depends="compile,validateDeploymentSettings">
+ <copy file="${jardrop.dir}/sample1.jar" todir="${axis.serverJarDrop.dir}" overwrite="true" />
+ <copy file="${jardrop.dir}/sample1WithHandler.jar" todir="${axis.serverJarDrop.dir}" overwrite="true" />
+ </target>
+
+ <target name="echo" depends="compile">
+ <java classname="userguide.sample1.SynchronousClient">
+ <classpath refid="classpath.runtimelibraries" />
+ <arg value="8080" />
+ <arg value="/axis2/services/sample1" />
+ </java>
+ </target>
+
+ <target name="echoWithHandler" depends="compile">
+ <java classname="userguide.sample1.SynchronousClient">
+ <classpath refid="classpath.runtimelibraries" />
+ <arg value="8080" />
+ <arg value="/axis2/services/sample1WithHandler" />
+ </java>
+ </target>
+
+ <target name="echoAsync" depends="compile">
+ <java classname="userguide.sample1.AsynchronousClient">
+ <classpath refid="classpath.runtimelibraries" />
+ <arg value="8080" />
+ <arg value="/axis2/services/sample1" />
+ </java>
+ </target>
+</project>
+
Added: webservices/axis/trunk/java/modules/samples/conf/service.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/conf/service.xml?view=auto&rev=154665
==============================================================================
--- webservices/axis/trunk/java/modules/samples/conf/service.xml (added)
+++ webservices/axis/trunk/java/modules/samples/conf/service.xml Mon Feb 21 02:39:27 2005
@@ -0,0 +1,4 @@
+<service provider="org.apache.axis.providers.RawXMLProvider" style="rpc" contextPath="services">
+ <java:implementation class="userguide.sample1.EchoXML" xmlns:java="http://ws.apache.org/axis2/deployment/java"/>
+ <operation name="echo" qname="echo"/>
+</service>
Added: webservices/axis/trunk/java/modules/samples/conf/service4withhandler.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/conf/service4withhandler.xml?view=auto&rev=154665
==============================================================================
--- webservices/axis/trunk/java/modules/samples/conf/service4withhandler.xml (added)
+++ webservices/axis/trunk/java/modules/samples/conf/service4withhandler.xml Mon Feb 21 02:39:27 2005
@@ -0,0 +1,23 @@
+<service provider="org.apache.axis.providers.RawXMLProvider" style="rpc" contextPath="services">
+ <java:implementation class="userguide.sample1.EchoXML" xmlns:java="http://ws.apache.org/axis2/deployment/java"/>
+
+ <inflow>
+ <handler name="LoggingHandler" class="userguide.sample1.LoggingHandler">
+ <!--Phase Ordering (e.g. phaseFirst="true") will be introdeced from M2-->
+ <order phase="Logging"/>
+ </handler>
+ </inflow>
+
+ <outflow>
+
+ </outflow>
+
+ <faultflow>
+ <handler name="LoggingHandler" class="userguide.sample1.LoggingHandler">
+ <!--Phase Ordering (e.g. phaseFirst="true") will be introdeced from M2-->
+ <order phase="Logging"/>
+ </handler>
+ </faultflow>
+
+ <operation name="echo" qname="echo"/>
+</service>
Added: webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/AsynchronousClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/AsynchronousClient.java?view=auto&rev=154665
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/AsynchronousClient.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/AsynchronousClient.java Mon Feb 21 02:39:27 2005
@@ -0,0 +1,87 @@
+
+package userguide.sample1;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.om.SOAPEnvelope;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+public class AsynchronousClient {
+
+ public static void main(String[] args) {
+ if(2 != args.length ){
+ System.out.println("Usage <Port> ");
+
+ }
+
+ System.out.println("Initializing the Client Call....");
+ Call call = new Call();
+ System.out.println("Setting the Endpointreference ");
+ URL url = null;
+ try {
+ url = new URL("http","127.0.0.1",new Integer(args[0]).intValue(),args[1]);
+ } catch (MalformedURLException e) {
+
+ e.printStackTrace();
+ System.exit(0);
+ }
+
+ call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url.toString()));
+
+
+ SOAPEnvelope requestEnvelop = ClientUtil.getEchoSoapEnvelop();
+ try {
+ call.setListenerTransport("http", true);
+
+ System.out.println("Sending the Async message ....");
+ XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
+ requestEnvelop.serialize(writer,true);
+ writer.flush();
+ System.out.println();
+
+ call.sendReceiveAsync(requestEnvelop, new ClientEchoCallbackHandler() );
+
+
+ } catch (AxisFault e1) {
+
+ e1.printStackTrace();
+ }
+ catch (XMLStreamException e){
+ e.printStackTrace();
+ }
+
+ System.out.println("Message sent and the client thread sleep till the responce ....");
+ try {
+ Thread.sleep(6000);
+ } catch (InterruptedException e2) {
+ System.exit(0);
+
+ }
+ }
+
+}
Added: webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/ClientEchoCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/ClientEchoCallbackHandler.java?view=auto&rev=154665
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/ClientEchoCallbackHandler.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/ClientEchoCallbackHandler.java Mon Feb 21 02:39:27 2005
@@ -0,0 +1,55 @@
+package userguide.sample1;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axis.clientapi.AsyncResult;
+import org.apache.axis.clientapi.Callback;
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+public class ClientEchoCallbackHandler extends Callback {
+
+
+ public void onComplete(AsyncResult result) {
+ System.out.println("Responce message received to the ClientEchoCallbackHandler ...");
+
+ try {
+ XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
+ result.getResponseEnvelope().serialize(writer,true);
+ writer.flush();
+ } catch (XMLStreamException e) {
+ System.out.println("Error occured after responce is received");
+ e.printStackTrace();
+ } catch (FactoryConfigurationError e) {
+ System.out.println("Error occured after responce is received");
+ e.printStackTrace();
+ }
+ System.out.println();
+
+ }
+
+
+ public void reportError(Exception e) {
+ System.out.println("Error occured after responce is received");
+ e.printStackTrace();
+
+ }
+
+}
Added: webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/ClientUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/ClientUtil.java?view=auto&rev=154665
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/ClientUtil.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/ClientUtil.java Mon Feb 21 02:39:27 2005
@@ -0,0 +1,42 @@
+
+package userguide.sample1;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.SOAPEnvelope;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+public class ClientUtil {
+
+ public static SOAPEnvelope getEchoSoapEnvelop(){
+ OMFactory omFactory = OMFactory.newInstance();
+ SOAPEnvelope envelope = omFactory.getDefaultEnvelope();
+ OMNamespace namespace = envelope.declareNamespace("http://sample1.org/sample1", "sample1");
+
+ OMElement bodyContent = omFactory.createOMElement("echo", namespace);
+
+
+ OMElement text = omFactory.createOMElement("Text", namespace);
+ text.addChild(omFactory.createText("Axis2 Echo String"));
+ bodyContent.addChild(text);
+ envelope.getBody().addChild(bodyContent);
+ return envelope;
+ }
+}
Modified: webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/EchoXML.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/EchoXML.java?view=diff&r1=154664&r2=154665
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/EchoXML.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/EchoXML.java Mon Feb 21 02:39:27 2005
@@ -1,20 +1,6 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
+
package userguide.sample1;
+
import org.apache.axis.om.OMElement;
public class EchoXML {
Added: webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/LoggingHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/LoggingHandler.java?view=auto&rev=154665
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/LoggingHandler.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/LoggingHandler.java Mon Feb 21 02:39:27 2005
@@ -0,0 +1,41 @@
+package userguide.sample1;
+
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.handlers.AbstractHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class LoggingHandler extends AbstractHandler {
+
+ private Log log = LogFactory.getLog(getClass());
+
+
+
+
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ log.info("Incomming message Frrom "+msgContext.getTo().getAddress());
+
+ }
+
+ public void revoke(MessageContext msgContext){
+ log.info("Incomming message Revovked at the server "+msgContext.getTo().getAddress() );
+ }
+
+}
Modified: webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/SynchronousClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/SynchronousClient.java?view=diff&r1=154664&r2=154665
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/SynchronousClient.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/java/userguide/sample1/SynchronousClient.java Mon Feb 21 02:39:27 2005
@@ -1,5 +1,22 @@
+package userguide.sample1;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axis.Constants;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.om.SOAPEnvelope;
+
/*
- * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,34 +30,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-package userguide.sample1;
-import org.apache.axis.Constants;
-import org.apache.axis.addressing.AddressingConstants;
-import org.apache.axis.addressing.EndpointReference;
-import org.apache.axis.clientapi.Call;
-import org.apache.axis.engine.AxisFault;
-import org.apache.axis.om.OMElement;
-import org.apache.axis.om.OMFactory;
-import org.apache.axis.om.OMNamespace;
-import org.apache.axis.om.SOAPEnvelope;
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
public class SynchronousClient {
public static void main(String[] args){
+ if(2 != args.length ){
+ System.out.println("Usage <Port> ");
+
+ }
System.out.println("Initializing the Client Call....");
Call call = new Call();
System.out.println("Setting the Endpointreference ");
URL url = null;
try {
- url = new URL("http","127.0.0.1",new Integer(args[0]).intValue(),"/axis2/services/sample1");
+ url = new URL("http","127.0.0.1",new Integer(args[0]).intValue(),args[1]);
} catch (MalformedURLException e) {
e.printStackTrace();
@@ -51,7 +55,7 @@
try {
call.setListenerTransport(Constants.SESSION_SCOPE, true);
- SOAPEnvelope requestEnvelop = getEchoSoapEnvelop();
+ SOAPEnvelope requestEnvelop = ClientUtil.getEchoSoapEnvelop();
System.out.println("Sending request...");
XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
@@ -77,19 +81,6 @@
}
- private static SOAPEnvelope getEchoSoapEnvelop(){
- OMFactory omFactory = OMFactory.newInstance();
- SOAPEnvelope envelope = omFactory.getDefaultEnvelope();
- OMNamespace namespace = envelope.declareNamespace("http://sample1.org/sample1", "sample1");
-
- OMElement bodyContent = omFactory.createOMElement("echo", namespace);
-
-
- OMElement text = omFactory.createOMElement("Text", namespace);
- text.addChild(omFactory.createText("Axis2 Echo String"));
- bodyContent.addChild(text);
- envelope.getBody().addChild(bodyContent);
- return envelope;
- }
+
}