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 2006/10/30 12:47:04 UTC
svn commit: r469129 - in
/webservices/axis2/branches/java/1_1/modules/samples/FaultHandling:
build.xml docs/ReadMe.html
Author: chinthaka
Date: Mon Oct 30 03:47:04 2006
New Revision: 469129
URL: http://svn.apache.org/viewvc?view=rev&rev=469129
Log:
Making sure client works. Need to update the documentation.
Modified:
webservices/axis2/branches/java/1_1/modules/samples/FaultHandling/build.xml
webservices/axis2/branches/java/1_1/modules/samples/FaultHandling/docs/ReadMe.html
Modified: webservices/axis2/branches/java/1_1/modules/samples/FaultHandling/build.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/FaultHandling/build.xml?view=diff&rev=469129&r1=469128&r2=469129
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/FaultHandling/build.xml (original)
+++ webservices/axis2/branches/java/1_1/modules/samples/FaultHandling/build.xml Mon Oct 30 03:47:04 2006
@@ -1,9 +1,10 @@
-<project basedir="." default="generate.service">
+<project basedir="." default="generate.all">
<property environment="env"/>
<property name="wsdl.uri" value="bank.wsdl"/>
- <property name="target" value="target"/>
+ <property name="service.target" value="target/service"/>
+ <property name="client.target" value="target/client"/>
<!-- Build the service, then the client. -->
<target name="jar">
@@ -16,24 +17,26 @@
<arg line="${url} ${account} ${amt}"/>
<classpath>
<pathelement location="BankService-test-client.jar"/>
- <fileset dir="${env.AXIS2_HOME}\lib">
+ <fileset dir="../../lib">
<include name="*.jar"/>
</fileset>
</classpath>
</java>
</target>
+ <target name="generate.all" depends="generate.service,gen.stub"/>
+
<target name="generate.service">
- <delete dir="${target}"/>
- <mkdir dir="${target}"/>
- <mkdir dir="${target}/classes"/>
-
+ <delete dir="${service.target}"/>
+ <mkdir dir="${service.target}"/>
+ <mkdir dir="${service.target}/classes"/>
+
<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
<arg line="-uri ${wsdl.uri}"/>
<arg line="-ss"/>
<arg line="-sd"/>
- <arg line="-o ${target}"/>
+ <arg line="-o ${service.target}"/>
<!-- Output directory in which to generate files --> <!-- NB it generates to the src folder under this directory!! -->
<classpath>
<fileset dir="../../lib">
@@ -43,12 +46,13 @@
</java>
<!--copy the already written skeleton class-->
- <copy file="service/src/example/BankServiceSkeleton.java" todir="${target}/src/example"
+ <copy file="service/src/example/BankServiceSkeleton.java"
+ todir="${service.target}/src/example"
overwrite="yes"/>
<!--First let's compile the classes-->
<javac debug="on" memoryMaximumSize="256m" memoryInitialSize="256m" fork="true"
- destdir="${target}/classes" srcdir="${target}/src">
+ destdir="${service.target}/classes" srcdir="${service.target}/src">
<classpath>
<fileset dir="../../lib">
<include name="*.jar"/>
@@ -57,16 +61,57 @@
</javac>
<!--aar them up -->
- <copy toDir="${target}/classes/META-INF" failonerror="false">
- <fileset dir="${target}/resources">
+ <copy toDir="${service.target}/classes/META-INF" failonerror="false">
+ <fileset dir="${service.target}/resources">
<include name="*.xml"/>
<include name="*.wsdl"/>
<include name="*.xsd"/>
</fileset>
</copy>
<jar destfile="BankService.aar">
- <fileset excludes="**/Test.class" dir="${target}/classes"/>
+ <fileset excludes="**/Test.class" dir="${service.target}/classes"/>
</jar>
</target>
+
+ <target name="gen.stub">
+ <delete dir="${client.target}"/>
+ <mkdir dir="${client.target}"/>
+ <mkdir dir="${client.target}/classes"/>
+ <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
+ <arg line="-uri ${wsdl.uri}"/>
+ <arg line="-u"/>
+ <arg line="-o ${client.target}"/>
+ <classpath>
+ <fileset dir="../../lib">
+ <include name="*.jar"/>
+ </fileset>
+ </classpath>
+ </java>
+
+ <copy file="client/src/example/BankClient.java" todir="${client.target}/src/example"/>
+
+ <!--now compile the stub classes-->
+ <javac debug="on" memoryMaximumSize="256m" memoryInitialSize="256m" fork="true"
+ destdir="${client.target}/classes">
+ <src path="${client.target}/src"/>
+ <classpath>
+ <fileset dir="../../lib">
+ <include name="*.jar"/>
+ </fileset>
+ </classpath>
+ </javac>
+
+ <!--jar the compiled stuff-->
+ <jar destfile="BankService-test-client.jar">
+ <fileset dir="${client.target}/classes">
+ <exclude name="**/META-INF/*.*"/>
+ <exclude name="**/lib/*.*"/>
+ <exclude name="**/*MessageReceiver.class"/>
+ <exclude name="**/*Skeleton.class"/>
+ </fileset>
+ </jar>
+ </target>
+
+
</project>
Modified: webservices/axis2/branches/java/1_1/modules/samples/FaultHandling/docs/ReadMe.html
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/FaultHandling/docs/ReadMe.html?view=diff&rev=469129&r1=469128&r2=469129
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/FaultHandling/docs/ReadMe.html (original)
+++ webservices/axis2/branches/java/1_1/modules/samples/FaultHandling/docs/ReadMe.html Mon Oct 30 03:47:04 2006
@@ -3,46 +3,60 @@
</head>
<body>
- <h1>
- Exception Handling using WSDL Faults
- </h1>
- <p>
- This example show cases how to specify a WSDL fault in order to allow
- your service to communicate exception pathways to your clients.
- </p>
- <p>
- Before you start you will need to set the <em>AXIS2_HOME</em> environment variable.
- </p>
- <h2>
- Constructing the Service and the Client.
- </h2>
- <p>
- The first step is to generate the service skeleton and other interface classes from the WSDL.
- </p>
- <p>
- Look at <em>bank.wsdl</em>.
- It defines the interface for our service. Of particular interest are
- the <strong>AccountNotExistFault</strong> and <strong>InsufficientFundFault</strong>
- types defined in the wsdl:types element.
- </p>
- <p>
- From a command prompt in the folder of this example,
- type <strong>ant generate.service</strong>. This will:
- <ul>
- <li>Generate the source for all the server classes in <strong>./service/target/src</strong></li>
- <li>
- Generate <em>services.xml</em> and a more complete
- <em>BankService.wsdl</em> into the <em>./service/target/resources</em> folder.
- </li>
- <li>
- Generate a <em>./service/target/build.xml</em> which can be used to
- build the service archive using Ant
- </li>
- </ul>
- </p>
- <p>
- Open up <em>./service/target/src/example/BankServiceSkeleton.java</em> and
- insert the code below into the <strong>#withdraw</strong> method.
+<h1>
+ Exception Handling using WSDL Faults
+</h1>
+
+<p>
+ This example show cases how to specify a WSDL fault in order to allow
+ your service to communicate exception pathways to your clients.
+</p>
+
+<p>
+ Running of this sample assumes that you are running this within the extracted release folder.
+</p>
+
+<h2>
+ Constructing the Service and the Client.
+</h2>
+
+<p>
+ The first step is to generate the service skeleton and other interface classes from the WSDL.
+</p>
+
+<p>
+ Look at <em>bank.wsdl</em>.
+ It defines the interface for our service. Of particular interest are
+ the <strong>AccountNotExistFault</strong> and <strong>InsufficientFundFault</strong>
+ types defined in the wsdl:types element.
+</p>
+
+<p>
+ From a command prompt in the folder of this example,
+ type <strong>ant generate.all</strong> or just <strong> ant</strong>. This will:
+ <ul>
+ <li>Generate the source for all the server classes in <strong>./service/target/src</strong>
+ </li>
+ <li>Generate <em>services.xml</em> and a more complete <em>BankService.wsdl</em> into
+ the <em>./service/target/resources</em> folder.
+ </li>
+ <li>
+ Generate a <em>./service/target/build.xml</em>
+ </li>
+ <li>Copies the pre-populated service skeleton class to the generated code</li>
+ <li>Compile the Java classes for the service</li>
+ <li>Create the service archive and copy it to <em>./BankService.aar</em></li>
+ <li>Generate the stubs (for the client) from the WSDL</li>
+ <li>Compile the client classes</li>
+ <li>Create a Jar of the client classes and copy it to <em>./BankService-test-client.jar</em>
+ </li>
+ </ul>
+</p>
+<p>
+ Open up <em>./service/target/src/example/BankServiceSkeleton.java</em> and
+ you will see the following code fragment inside <strong>#withdraw</strong> method. When
+ generate.service was being executed, Axis2 generates an empty skeleton class and we replace it
+ with a pre-populated skeleton class which has the following code inside it.
<pre>
final String account = param0.getAccount();
@@ -69,46 +83,43 @@
response.setBalance(1000 - amount);
return response;
</pre>
- </p>
- <p>
- From a command prompt in the folder of this sample (samples/FaultHandling), type <strong>ant jar</strong>. This will
-
- and create the service archive at <em>./service/target/build/lib/BankService.aar</em>
- <ul>
- <li>Compile the Java classes for the service</li>
- <li>Create the service archive and copy it to <em>./BankService.aar</em></li>
- <li>Generate the stubs (for the client) from the WSDL</li>
- <li>Compile the client classes</li>
- <li>Create a Jar of the client classes and copy it to <em>./BankService-test-client.jar</em></li>
- </ul>
- </p>
- <p>
- Note that the source generated for the client will include the 2 faults and the local Exceptions
- through which they will be transmitted. Note that the Exceptions are generated within the <em>BankStub</em> class.
- </p>
-
- <h2>
- Running the Client.
- </h2>
- <p>
- Deploy the service archive (BankService.aar) to the Axis2 web application.
- </p>
- <p>
- Invoke the <em>example.BankClient</em> class. You may use the command scripts to do so.
- You need to supply 3 parameters to the command, url, account and amount.
- <ul>
- <li>
- <strong>ant client -Durl=http://localhost:8080/axis2/services/BankService -Daccount=13 -Damt=400</strong><br/>
- Throws AccountNotExistFaultMessageException. You will see "Account#13 does not exist"<br/>
- </li>
- <li>
- <strong>ant client -Durl=http://localhost:8080/axis2/services/BankService -Daccount=88 -Damt=1200</strong><br/>
- Throws InsufficientFundsFaultMessageException. You will see "Account#88 has balance of 1000. It cannot support withdrawal of 1200"<br/>
- </li>
- <li>
- <strong>ant client -Durl=http://localhost:8080/axis2/services/BankService -Daccount=88 -Damt=400</strong><br/>
- Succeeds with a balance of 600. You will see "Balance = 600"<br/>
- </li>
- </ul>
- </p>
+</p>
+
+<p>
+ Note that the source generated for the client will include the 2 faults and the local Exceptions
+ through which they will be transmitted. Note that the Exceptions are generated within the <em>BankStub</em>
+ class.
+</p>
+
+<h2>
+ Running the Client.
+</h2>
+
+<p>
+ Deploy the service archive (BankService.aar) to the Axis2 web application.
+</p>
+
+<p>
+ Invoke the <em>example.BankClient</em> class. You may use the command scripts to do so.
+ You need to supply 3 parameters to the command, url, account and amount.
+ <ul>
+ <li>
+ <strong>ant client -Durl=http://localhost:8080/axis2/services/BankService -Daccount=13
+ -Damt=400</strong><br/>
+ Throws AccountNotExistFaultMessageException. You will see "Account#13 does not
+ exist"<br/>
+ </li>
+ <li>
+ <strong>ant client -Durl=http://localhost:8080/axis2/services/BankService -Daccount=88
+ -Damt=1200</strong><br/>
+ Throws InsufficientFundsFaultMessageException. You will see "Account#88 has balance of
+ 1000. It cannot support withdrawal of 1200"<br/>
+ </li>
+ <li>
+ <strong>ant client -Durl=http://localhost:8080/axis2/services/BankService -Daccount=88
+ -Damt=400</strong><br/>
+ Succeeds with a balance of 600. You will see "Balance = 600"<br/>
+ </li>
+ </ul>
+</p>
</body>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org