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 ba...@apache.org on 2008/04/04 21:31:02 UTC
svn commit: r644843 - in
/webservices/axis2/trunk/java/modules/samples/jaxws-addressbook: README.txt
src/org/apache/axis2/jaxws/addressbook/AddressBook.java
src/org/apache/axis2/jaxws/addressbook/AddressBookClient.java
Author: barrettj
Date: Fri Apr 4 12:31:00 2008
New Revision: 644843
URL: http://svn.apache.org/viewvc?rev=644843&view=rev
Log:
Update ReadMe and add some comments for sample
Modified:
webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/README.txt
webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/src/org/apache/axis2/jaxws/addressbook/AddressBook.java
webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/src/org/apache/axis2/jaxws/addressbook/AddressBookClient.java
Modified: webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/README.txt
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/README.txt?rev=644843&r1=644842&r2=644843&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/README.txt (original)
+++ webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/README.txt Fri Apr 4 12:31:00 2008
@@ -6,20 +6,12 @@
3. Write a Dispatch client to interact with the service
4. Run the Dispatch client against the service implementation deployed in the Axis2 server
-This will be an address book sample based on one of the jaxws-integration tests:
+This address book sample is based on one of the jaxws-integration tests:
modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addressbook
Note that this is a very simple example, and does not persist any data. The intent is
to illustrate the use of JAXB objects with JAX-WS, not to actually implement and address book.
-The directory structure and environment setup in this example is as follows. You should modify
-the example directories based on your environment.
-- Axis2 binary distribution: AXIS2_HOME=C:\temp\Axis2\axis2-SNAPSHOT
-- Java5 JDK: JAVA_HOME=c:\java\java5
-- This example source is in: C:\blddir\eclipse\axis2\jaxws-addressbook
-
-Note that JAVA_HOME is assumed to be on PATH.
-
The following source is included with this example:
src\AddressBookEntry.xsd: Schema used to generate JAXB artifacts
src\org\apache\axis2\jaxws\addressbook\AddressBook.java: JAXWS Service Endpoint Interface (SEI)
@@ -27,11 +19,19 @@
src\org\apache\axis2\jaxws\addressbook\AddressBookClient.java: JAXWS Dispatch Client
src\org\apache\axis2\jaxws\addressbook\AddressBookImpl.java: JAXWS service implementation
-Note that this ReadMe was created with the example in an Eclipse project with the following
-structure:
-- 'src' source folder containing the example source
-- 'jaxb' source folder containing the generated JAXB artifacts from Step 1
-- 'bin' directory containing all of the output (including the compiled classes)
+
+Step 0: How to build this sample
+================================
+To build this sample, execute the following maven command:
+ mvn clean install
+
+This will do the following:
+- Generate the JAXB artifacts (in target/schema)
+- Compile the service implementation classes (in target/classes), including the JAXB artifacts,
+ and create a JAR containing those classes (target/jaxws-addressbook-SNAPSHOT.jar)
+- Compile the Dispatch client classes (in target/classes) and create a JAR containing those classes
+ (target/jaxws-addressbook-SNAPSHOT-Client.jar).
+
Step 1: Generate JAXB artifacts from simple schema
==================================================
@@ -44,16 +44,14 @@
String city;
String state;
-To generate the JAXB beans for this schema, run the following command in the 'src' directory:
-java -Djava.ext.dirs=C:\temp\Axis2\axis2-SNAPSHOT\lib;C:\java\java5\jre\lib\ext com.sun.tools.xjc.Driver -d jaxb src\AddressBookEntry.xsd
-
-This will generate the following JAXB artifacts:
+The following JAXB artifacts are generated in the target/schema/src directory when the
+sample is built
org\apache\axis2\jaxws\addressbook\AddressBookEntry.java
org\apache\axis2\jaxws\addressbook\ObjectFactory.java
org\apache\axis2\jaxws\addressbook\package-info.java
-You can compile these files now or later in Step 3 with the rest of the java files. See Step 3
-for the 'javac' command.
+These files will be compiled into target/classes as part of the build.
+
Step 2: Write a JAX-WS service implementation using the JAXB artifacts
======================================================================
@@ -61,53 +59,62 @@
public String addEntry(String firstName, String lastName, String phone, String street, String city, String state)
public AddressBookEntry findByLastName(String lastName)
-The service implentation does not explicitly specify a JAX-WS SEI. The public methods on the
-implementation are an implicit SEI. Simply by adding an @WebService annotation to the implementation
-it becomes a JAX-WS web service.
+The service implementation does not explicitly specify a JAX-WS SEI. The public methods on the
+implementation will be an implicit SEI. Simply by adding an @WebService annotation to the
+implementation class it becomes a JAX-WS web service.
+
+The implementation class is: src\org\apache\axis2\jaxws\addressbook\AddressBookImpl.java
-See src\org\apache\axis2\jaxws\addressbook\AddressBookImpl.java
+This file will be compiled into target/classes as part of the build.
-You can compile these files now or later in Step 3 with the rest of the java files. See Step 3
-for the 'javac' command.
Step 3: Write a JAX-WS Dispatch client to interact with the service
===================================================================
-The extremely simple Dispatch client will use be a Payload mode String Dispatch client meaning that
+The extremely simple Dispatch client will be a Payload mode String Dispatch client, meaning that
it will provide the exact SOAP body to send in the request (Payload mode) as a String, and expect
the response to be a SOAP body returned as a String. It will invoke both methods on the
service implenetation's implicit SEI.
+The dispatch client class is: src\org\apache\axis2\jaxws\addressbook\AddressBookClient.java
+
+This file will be compiled into target/classes as part of the build.
+
+
Step 4: Run the Dispatch client against the service implementation deployed in the Axis2 server
===============================================================================================
-(a) First compile the generated JAXB artifacts, the service implementation, and the dispatch client.
-Note that if you are using Eclipse, this step will not be necessary; Eclipse will have compiled the
-classes into the 'bin' directory.
-javac -Djava.ext.dirs=C:\temp\Axis2\axis2-SNAPSHOT\lib;C:\java\java5\jre\lib\ext -classpath C:\blddir\eclipse\axis2\jaxws-addressbook\bin *.java
-
-(b) Then create a JAR file containg the service implementation and copy it to
-the axis2 repository/servicejars directory. This will cause it to be deployed when the axis2
-server is started. Note that in this example, the service implementation jar will also contain
-the client classes; this is not necessary; it is done to simplify the example. From the directory
-above 'org' which contains the compiled classes from (a):
-jar -cvf AddressBook.jar org
-mkdir C:\temp\Axis2\axis2-SNAPSHOT\repository\servicejars
-copy AddressBook.jar C:\temp\Axis2\axis2-SNAPSHOT\repository\servicejars
+(a) Setup your environment to run the sample. You will need two windows, one for the server
+and one for the client. Each needs the following environment variables set:
+- Axis2 binary distribution. For example: AXIS2_HOME=C:\temp\Axis2\axis2-SNAPSHOT
+- Java5 JDK. For example: JAVA_HOME=c:\java\java5
+
+(b) Copy the service implementation JAR file from the sample target directory to the appropriate
+Axis2 repository directory, %AXIS2_HOME%\repository\servicejars. Note that JAR files in this
+directory will be deployed into the Axis2 simple server using only annotations on classes
+within the JARs; no deployment descriptor is required.
+
+If the repository directory does not exist, create it first, then copy the service
+implementation JAR:
+ mkdir %AXIS2_HOME%\repository\servicejars
+ copy target\jaxws-addressbook-SNAPSHOT.jar %AXIS2_HOME%\repository\servicejars
(c) Start the axis2 server. This will deploy the JAX-WS service implementation.
-set AXIS2_HOME=C:\temp\Axis2\axis2-SNAPSHOT
-bin\axis2server.bat
+ cd %AXIS2_HOME%
+ bin\axis2server.bat
You should see a message such as:
-[INFO] Deploying artifact : AddressBook.jar
+[INFO] Deploying artifact : jaxws-addressbook-SNAPSHOT.jar
[INFO] Deploying JAXWS annotated class org.apache.axis2.jaxws.addressbook.AddressBookImpl as a service - AddressBookImplService.AddressBookImplPort
-(d) From another window with the environment setup, run the Dispatch client:
-java -Djava.ext.dirs=C:\temp\Axis2\axis2-SNAPSHOT\lib;C:\java\java5\jre\lib\ext -cp C:\blddir\eclipse\axis2\jaxws-addressbook\bin org.apache.axis2.jaxws.addressbook.AddressBookClient.class
+(d) From another window with the environment setup, in the jaxws-addressbook samples directory run
+the Dispatch client:
+ java -Djava.ext.dirs=%AXIS2_HOME%\lib;%JAVA_HOME%\jre\lib\ext -cp target/classes org.apache.axis2.jaxws.addressbook.AddressBookClient.class
-Thoughts on improvmenets
-========================
-1. Extend the simple schema to include the request and response messages, generate those beans
- with xjc, and then use them in the Dispatch client instead of the String messages
-2. Make use of the JAXWS SEI by specifying an @WebService annotation on it and
- and @WebService.endpointInterface on the serivice implementation
\ No newline at end of file
+You should see something like the following in the client window:
+>> Invoking sync Dispatch for AddEntry
+Add Entry response: <dlwmin:addEntryResponse xmlns:dlwmin="http://addressbook.jaxws.axis2.apache.org/"><return xmlns:ns2
+="http://addressbook.jaxws.axis2.apache.org">AddEntry Completed!</return></dlwmin:addEntryResponse>
+>> Invoking Dispatch for findByLastName
+Find response: <dlwmin:findByLastNameResponse xmlns:dlwmin="http://addressbook.jaxws.axis2.apache.org/"><return xmlns:ns
+2="http://addressbook.jaxws.axis2.apache.org"><firstName>firstName</firstName><lastName>lastName</lastName><phone>phone<
+/phone><street>street</street><city>city</city><state>state</state></return></dlwmin:findByLastNameResponse>
Modified: webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/src/org/apache/axis2/jaxws/addressbook/AddressBook.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/src/org/apache/axis2/jaxws/addressbook/AddressBook.java?rev=644843&r1=644842&r2=644843&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/src/org/apache/axis2/jaxws/addressbook/AddressBook.java (original)
+++ webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/src/org/apache/axis2/jaxws/addressbook/AddressBook.java Fri Apr 4 12:31:00 2008
@@ -1,6 +1,11 @@
package org.apache.axis2.jaxws.addressbook;
-// NOTE: This Service Endpoint Interface (SEI) is NOT CURRENTLY USED in this example
+/**
+ * The JAX-WS Service Endpoint Interface (SEI).
+ *
+ * NOTE: The SEI is NOT USED in this example. The service implementation publishing all public
+ * methods as an implicit SEI.
+ */
public interface AddressBook {
Modified: webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/src/org/apache/axis2/jaxws/addressbook/AddressBookClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/src/org/apache/axis2/jaxws/addressbook/AddressBookClient.java?rev=644843&r1=644842&r2=644843&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/src/org/apache/axis2/jaxws/addressbook/AddressBookClient.java (original)
+++ webservices/axis2/trunk/java/modules/samples/jaxws-addressbook/src/org/apache/axis2/jaxws/addressbook/AddressBookClient.java Fri Apr 4 12:31:00 2008
@@ -7,6 +7,9 @@
import java.util.Map;
+/**
+ * Simple JAX-WS Dispatch client for the address book service implementation.
+ */
public class AddressBookClient {
private static String NAMESPACE = "http://addressbook.jaxws.axis2.apache.org";
private static QName QNAME_SERVICE = new QName(NAMESPACE, "service");
@@ -30,19 +33,25 @@
public static void main(String[] args) {
try {
- Service svc = Service.create(QNAME_SERVICE);
- svc.addPort(QNAME_PORT, null, ENDPOINT_URL);
- Dispatch<String> dispatch = svc.createDispatch(QNAME_PORT,
- String.class, Service.Mode.PAYLOAD);
+ System.out.println("AddressBookClient ...");
- // Invoke the Dispatch
- System.out.println(">> Invoking sync Dispatch for AddEntry");
- String response = dispatch.invoke(ADD_ENTRY_BODY_CONTENTS);
- System.out.println("Add Entry (void) Response: " + response);
-
- System.out.println(">> Invoking Dispatch for findByLastName");
- String response2 = dispatch.invoke(FIND_BODY_CONTENTS);
- System.out.println("Find response: " + response2);
+ Service svc = Service.create(QNAME_SERVICE);
+ svc.addPort(QNAME_PORT, null, ENDPOINT_URL);
+
+ // A Dispatch<String> client sends the request and receives the response as
+ // Strings. Since it is PAYLOAD mode, the client will provide the SOAP body to be
+ // sent; the SOAP envelope and any required SOAP headers will be added by JAX-WS.
+ Dispatch<String> dispatch = svc.createDispatch(QNAME_PORT,
+ String.class, Service.Mode.PAYLOAD);
+
+ // Invoke the Dispatch
+ System.out.println(">> Invoking sync Dispatch for AddEntry");
+ String response = dispatch.invoke(ADD_ENTRY_BODY_CONTENTS);
+ System.out.println("Add Entry response: " + response);
+
+ System.out.println(">> Invoking Dispatch for findByLastName");
+ String response2 = dispatch.invoke(FIND_BODY_CONTENTS);
+ System.out.println("Find response: " + response2);
} catch (Exception e) {
System.out.println("Caught exception: " + e);
e.printStackTrace();
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org