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 sa...@apache.org on 2006/10/27 06:29:23 UTC

svn commit: r468267 - in /webservices/axis2/branches/java/1_1/modules/samples/pojo: ./ src/ src/META-INF/ src/address_book_client/ src/address_book_entry/ src/address_book_service/

Author: sanka
Date: Thu Oct 26 21:29:20 2006
New Revision: 468267

URL: http://svn.apache.org/viewvc?view=rev&rev=468267
Log:
Added the new POJO sample


Added:
    webservices/axis2/branches/java/1_1/modules/samples/pojo/build.xml
    webservices/axis2/branches/java/1_1/modules/samples/pojo/src/
    webservices/axis2/branches/java/1_1/modules/samples/pojo/src/META-INF/
    webservices/axis2/branches/java/1_1/modules/samples/pojo/src/META-INF/services.xml
    webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_client/
    webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_client/AddressBookClient.java
    webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_entry/
    webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_entry/Entry.java
    webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_service/
    webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_service/AddressBookService.java

Added: webservices/axis2/branches/java/1_1/modules/samples/pojo/build.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/pojo/build.xml?view=auto&rev=468267
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/pojo/build.xml (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/pojo/build.xml Thu Oct 26 21:29:20 2006
@@ -0,0 +1,48 @@
+<project basedir="." default="build">
+
+	<property environment="env" />
+
+	<property name="dest.dir" value="target" />
+
+	<property name="dest.dir.classes" value="${dest.dir}/classes" />
+
+	<property name="dest.dir.lib" value="${dest.dir}/lib" />
+
+	<path id="build.class.path">
+		<fileset dir="${env.AXIS2_HOME}/lib">
+			<include name="*.jar" />
+		</fileset>
+	</path>
+
+	<target name="clean">
+		<delete dir="${dest.dir}" />
+	</target>
+
+	<target name="prepare" depends="clean">
+
+		<mkdir dir="${dest.dir}" />
+
+		<mkdir dir="${dest.dir.classes}" />
+
+		<mkdir dir="${dest.dir.classes}/META-INF" />
+
+	</target>
+
+	<target name="build" depends="prepare">
+
+		<mkdir dir="${dest.dir}" />
+
+		<mkdir dir="${dest.dir.classes}" />
+		<mkdir dir="${dest.dir.classes}/META-INF" />
+
+		<copy file="src/META-INF/services.xml" tofile="${dest.dir.classes}/META-INF/services.xml" overwrite="true" />
+
+		<javac srcdir="src" destdir="${dest.dir.classes}" includes="address_book_service/**,address_book_entry/**">
+			<classpath refid="build.class.path" />
+		</javac>
+
+		<jar basedir="${dest.dir.classes}" destfile="${dest.dir}/AddressBookService.aar" />
+
+	</target>
+
+</project>
\ No newline at end of file

Added: webservices/axis2/branches/java/1_1/modules/samples/pojo/src/META-INF/services.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/pojo/src/META-INF/services.xml?view=auto&rev=468267
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/pojo/src/META-INF/services.xml (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/pojo/src/META-INF/services.xml Thu Oct 26 21:29:20 2006
@@ -0,0 +1,11 @@
+<service name="AddressBookService" scope="application">
+    <parameter name="ServiceClass" locked="false">address_book_service.AddressBookService</parameter>
+    <operation name="addEntry">
+        <actionMapping>urn:addEntry</actionMapping>
+        <messageReceiver class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
+    </operation>
+    <operation name="findEntry">
+        <actionMapping>urn:findEntry</actionMapping>
+        <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
+    </operation>
+</service>
\ No newline at end of file

Added: webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_client/AddressBookClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_client/AddressBookClient.java?view=auto&rev=468267
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_client/AddressBookClient.java (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_client/AddressBookClient.java Thu Oct 26 21:29:20 2006
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+package address_book_client;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.rpc.client.RPCServiceClient;
+
+import address_book_entry.Entry;
+
+
+public class AddressBookClient {
+
+    public static void main(String[] args1) throws AxisFault {
+
+        RPCServiceClient serviceClient = new RPCServiceClient();
+
+        Options options = serviceClient.getOptions();
+
+        EndpointReference targetEPR = new EndpointReference(
+                "http://127.0.0.1:8080/axis2/services/AdressBookService");
+        options.setTo(targetEPR);
+
+        // /////////////////////////////////////////////////////////////////////
+
+        /*
+         * Creates an Entry and stores it in the AddressBook.
+         */
+
+        // QName of the target method 
+        QName opAddEntry = new QName("http://address_book_service/xsd", "addEntry");
+
+        /*
+         * Constructing a new Entry
+         */
+        Entry entry = new Entry();
+
+        entry.setName("Abby Cadabby");
+        entry.setStreet("Sesame Street");
+        entry.setCity("Sesame City");
+        entry.setState("Sesame State");
+        entry.setPostalCode("11111");
+
+        // Constructing the arguments array for the method invocation
+        Object[] opAddEntryArgs = new Object[] { entry };
+
+        // Invoking the method
+        serviceClient.invokeRobust(opAddEntry, opAddEntryArgs);
+
+        ////////////////////////////////////////////////////////////////////////
+        
+        
+        ///////////////////////////////////////////////////////////////////////
+        
+        /*
+         * Fetching an Entry from the Address book
+         */
+        
+        // QName of the method to invoke 
+        QName opFindEntry = new QName("http://address_book_service/xsd", "findEntry");
+
+        //
+        String name = "Abby Cadabby";
+
+        Object[] opFindEntryArgs = new Object[] { name };
+        Object[] returnTypes = new Object[] { Entry.class };
+
+        
+        Object[] response = serviceClient.invokeBlocking(opFindEntry,
+                opFindEntryArgs, returnTypes);
+        
+        Entry result = (Entry) response[0];
+        
+        if (result == null) {
+            System.out.println("No entry found for " + name);
+            return;
+        } 
+        
+        System.out.println("Name   :" + result.getName());
+        System.out.println("Street :" + result.getStreet());
+        System.out.println("City   :" + result.getCity());
+        System.out.println("State  :" + result.getState());
+        System.out.println("Postal Code :" + result.getPostalCode());
+        
+
+        ///////////////////////////////////////////////////////////////////////
+    }
+}

Added: webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_entry/Entry.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_entry/Entry.java?view=auto&rev=468267
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_entry/Entry.java (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_entry/Entry.java Thu Oct 26 21:29:20 2006
@@ -0,0 +1,70 @@
+package address_book_entry;
+/*
+ * 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 Entry {
+    
+    private String name = null;
+    
+    private String street = null;
+    
+    private String city = null;
+    
+    private String state = null;
+    
+    private String postalCode = null;
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPostalCode() {
+        return postalCode;
+    }
+
+    public void setPostalCode(String postalCode) {
+        this.postalCode = postalCode;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public String getStreet() {
+        return street;
+    }
+
+    public void setStreet(String street) {
+        this.street = street;
+    }
+    
+}

Added: webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_service/AddressBookService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_service/AddressBookService.java?view=auto&rev=468267
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_service/AddressBookService.java (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/pojo/src/address_book_service/AddressBookService.java Thu Oct 26 21:29:20 2006
@@ -0,0 +1,30 @@
+package address_book_service;
+
+
+import java.util.HashMap;
+
+import address_book_entry.Entry;
+
+
+public class AddressBookService {
+    
+    private HashMap entries = new HashMap();
+
+    /**
+     * Add an Entry to the Address Book
+     * @param entry
+     */
+    public void addEntry(Entry entry) {
+        this.entries.put(entry.getName(), entry);
+    }
+    
+    /**
+     * Search an address of a person
+     * 
+     * @param name the name of the person whose address needs to be found
+     * @return return the address entry of the person. 
+     */
+    public Entry findEntry(String name) {
+        return (Entry) this.entries.get(name);
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org