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 de...@apache.org on 2005/10/18 12:03:08 UTC

svn commit: r326069 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/rpc/client/ codegen/src/org/apache/axis2/rpc/receivers/ codegen/src/org/apache/axis2/util/ core/test-resources/deployment/ integration/test/org/apache/axis2/rpc/

Author: deepal
Date: Tue Oct 18 03:02:28 2005
New Revision: 326069

URL: http://svn.apache.org/viewcvs?rev=326069&view=rev
Log:
I just Implement RPC client side , introduced RPCCall which can be used to invoke RPC calls. RPCCall extends from Call class (if there is any objection I can change that). I have some problems on return type of the RPCCall that has to be solved. 

I have used RPCMessageReciver which is a message receiver implemented on java repletion , and I am thinking of integrating that with RPCInOutMessageReciver , there are something to be solved on that , after that we will removed one of them :)  

Added:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCCall.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCRequestParameter.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/AddressBean.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MyBean.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java
Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/BeanSerializer.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/SimpleTypeMapper.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
    webservices/axis2/trunk/java/modules/core/test-resources/deployment/service1.xml

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCCall.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCCall.java?rev=326069&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCCall.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCCall.java Tue Oct 18 03:02:28 2005
@@ -0,0 +1,173 @@
+package org.apache.axis2.rpc.client;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.rpc.RPCParameter;
+import org.apache.axis2.rpc.receivers.SimpleTypeMapper;
+import org.apache.axis2.databinding.utils.ADBPullParser;
+import org.apache.axis2.clientapi.Call;
+import org.apache.axis2.clientapi.Callback;
+import org.apache.axis2.clientapi.InOutMEPClient;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.OperationDescription;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.wsdl.WSDLConstants;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import java.util.ArrayList;
+/*
+* 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.
+*
+*
+*/
+
+/**
+ * Author: Deepal Jayasinghe
+ * Date: Oct 13, 2005
+ * Time: 10:37:52 AM
+ */
+public class RPCCall extends Call {
+
+
+    protected static OperationDescription operationTemplate;
+
+    /**
+     * @throws org.apache.axis2.AxisFault
+     */
+
+    public RPCCall() throws AxisFault {
+        super(assumeServiceContext(null));
+    }
+
+    /**
+     * This is used to create call object with client home , using only this constructor it can
+     * able to engage modules  , addning client side parameters
+     *
+     * @param clientHome
+     * @throws org.apache.axis2.AxisFault
+     */
+    public RPCCall(String clientHome) throws AxisFault {
+        super(assumeServiceContext(clientHome));
+    }
+
+    /**
+     * @param service
+     * @see InOutMEPClient constructer
+     */
+    public RPCCall(ServiceContext service) {
+        super(service);
+    }
+
+    /**
+     * Return value can be a single a object or an object array (itself an object) , but it is
+     * difficulty to figure the return object correctly unless we have TyepMapping in the client
+     *  side too. Until it is finalized lets return OMElement as return value. And the retuen
+     * value will be the body first element user has to deal with that and create
+     * his own object out of that.
+     * @param opName  Operation QName (to get the body wrapper element)
+     * @param args Arraylist of objects
+     * @return  Response OMElement
+     */
+    public OMElement invokeBlocking(QName opName , Object [] args) throws AxisFault {
+        OperationDescription opDesc =
+                serviceContext.getServiceConfig().getOperation(opName);
+        opDesc = createOpDescAndFillInFlowInformation(opDesc, opName.getLocalPart(),
+                WSDLConstants.MEP_CONSTANT_IN_OUT);
+        opDesc.setParent(serviceContext.getServiceConfig());
+        MessageContext msgctx = prepareTheSOAPEnvelope(getOMElement(opName,args));
+
+        this.lastResponseMessage = super.invokeBlocking(opDesc, msgctx);
+        SOAPEnvelope resEnvelope = lastResponseMessage.getEnvelope();
+        return resEnvelope.getBody().getFirstElement();
+    }
+
+    /**
+     * Invoke the nonblocking/Asynchronous call
+     *
+     * @param opName
+     * @param args   -  This should be OM Element (payload)
+     *                 invocation behaves accordingly
+     * @param callback
+     * @throws org.apache.axis2.AxisFault
+     */
+
+    public void invokeNonBlocking(
+            QName opName,
+            Object [] args,
+            Callback callback)
+            throws AxisFault {
+        OperationDescription opDesc =
+                serviceContext.getServiceConfig().getOperation(opName);
+        opDesc = createOpDescAndFillInFlowInformation(opDesc, opName.getLocalPart(), WSDLConstants.MEP_CONSTANT_IN_OUT);
+        MessageContext msgctx = prepareTheSOAPEnvelope(getOMElement(opName,args));
+        //call the underline implementation
+        super.invokeNonBlocking(opDesc, msgctx, callback);
+    }
+
+    /**
+     * This method is used to get OMElement out from an Object array , the object array can contain
+     * either RPCRequestParamter or Object (if it is object that should be either JavaBean or a Simple
+     * TypeObject , other types of object can not handle yet)
+     * @param opName
+     * @param args
+     * @return
+     * @throws AxisFault
+     */
+    private OMElement getOMElement(QName opName ,Object [] args) throws AxisFault {
+        ArrayList objects ;
+        try {
+            objects = new ArrayList();
+            int argCount =0;
+            for (int i = 0; i < args.length; i++) {
+                Object arg = args[i];
+                if(arg instanceof RPCParameter){
+                    RPCRequestParameter para = (RPCRequestParameter)arg;
+                    objects.add(para.getName());
+                    objects.add(para.getValue());
+                    if (para.isSimpletype()) {
+                        objects.add(para.getName());
+                        objects.add(para.getValue().toString());
+                    } else {
+                        objects.add(para.getName());
+                        objects.add(para.getValue().toString());
+                    }
+                } else {
+                    if(SimpleTypeMapper.isSimpleType(arg)){
+                        objects.add("arg" + argCount);
+                        objects.add(arg.toString());
+                    }  else {
+                        objects.add(new QName("arg" + argCount));
+                        objects.add(arg);
+                    }
+                    argCount ++;
+                }
+            }
+            XMLStreamReader xr = ADBPullParser.createPullParser(opName,objects.toArray(),null);
+            StAXOMBuilder stAXOMBuilder =
+                    OMXMLBuilderFactory.createStAXOMBuilder(
+                            OMAbstractFactory.getSOAP11Factory(), xr);
+            return stAXOMBuilder.getDocumentElement();
+        } catch (ClassCastException e) {
+            throw new AxisFault("Object is not a RPCRequestParameter" + e);
+        }
+
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCRequestParameter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCRequestParameter.java?rev=326069&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCRequestParameter.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCRequestParameter.java Tue Oct 18 03:02:28 2005
@@ -0,0 +1,88 @@
+package org.apache.axis2.rpc.client;
+
+import org.apache.axis2.rpc.receivers.SimpleTypeMapper;
+
+import javax.xml.namespace.QName;
+/*
+* 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.
+*
+*
+*/
+
+/**
+ * Author: Deepal Jayasinghe
+ * Date: Oct 13, 2005
+ * Time: 10:43:45 AM
+ */
+public class RPCRequestParameter {
+
+    private QName name;
+    private Object value;
+
+    public QName getName() {
+        return name;
+    }
+
+    public void setName(QName name) {
+        this.name = name;
+    }
+
+    public Object getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+
+    public void setValue(int value) {
+        this.value = new Integer(value);
+    }
+
+    public void setValue(byte value) {
+        this.value = new Byte(value);
+    }
+
+    public void setValue(short value) {
+        this.value = new Short(value);
+    }
+
+
+    public void setValue(long value) {
+        this.value = new Long(value);
+    }
+
+    public void setValue(double value) {
+        this.value = new Double(value);
+    }
+
+    public void setValue(char value) {
+        this.value = new Character(value);
+    }
+
+    public void setValue(boolean value) {
+        this.value = (value) ? Boolean.TRUE : Boolean.FALSE;
+    }
+
+    public void setValue(Object value) {
+        this.value = value;
+    }
+
+    public boolean isSimpletype() {
+        return SimpleTypeMapper.isSimpleType(value);
+    }
+
+}

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/BeanSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/BeanSerializer.java?rev=326069&r1=326068&r2=326069&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/BeanSerializer.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/BeanSerializer.java Tue Oct 18 03:02:28 2005
@@ -1,10 +1,17 @@
 package org.apache.axis2.rpc.receivers;
-import org.apache.axis2.om.OMElement;
+
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.om.OMElement;
+import org.omg.PortableInterceptor.Interceptor;
 
-import java.util.Iterator;
-import java.util.HashMap;
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.beans.Introspector;
+import java.beans.IntrospectionException;
+import java.beans.BeanInfo;
+import java.beans.PropertyDescriptor;
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
 *
@@ -42,7 +49,7 @@
     }
 
     public Object deserilze() throws AxisFault {
-        Object beanObj ;
+        Object beanObj =null;
         try {
             beanObj = beanClass.newInstance();
             Iterator elements = beanElement.getChildren();
@@ -51,21 +58,25 @@
                 String partsLocalName = parts.getLocalName();
 
                 //getting the setter field
-                Field field =(Field)fields.get(partsLocalName);
-                if(field == null){
+//                Field field = (Field) fields.get(partsLocalName);
+                PropertyDescriptor field =(PropertyDescriptor)fields.get(partsLocalName.toLowerCase());
+                if (field == null) {
                     throw new AxisFault("User Error , In vaild bean ! field does not exist " + "set" +
                             partsLocalName);
                 } else {
-                    Class parameters = field.getType();
-                    Object partObj = SimpleTypeMapper.getSimpleTypeObject(parameters,parts);
-                    if(partObj == null){
+                    Class parameters = field.getPropertyType();
+                    if (field.equals("class"))
+                        continue;
+                    Object partObj = SimpleTypeMapper.getSimpleTypeObject(parameters, parts);
+                    if (partObj == null) {
                         // Assuming paramter itself as a bean
-                        partObj = new BeanSerializer(parameters,parts).deserilze();
+                        partObj = new BeanSerializer(parameters, parts).deserilze();
                     }
-//                    Object [] parms = new Object[]{partObj};
-                    field.setAccessible(true);
-                    field.set(beanObj,partObj);
-                    field.setAccessible(false);
+                    Object [] parms = new Object[]{partObj};
+//                    field.setAccessible(true);
+//                    field.set(beanObj, partObj);
+//                    field.setAccessible(false);
+                    field.getWriteMethod().invoke(beanObj,parms);
                 }
 
 
@@ -74,6 +85,8 @@
             throw new AxisFault("InstantiationException : " + e);
         } catch (IllegalAccessException e) {
             throw new AxisFault("IllegalAccessException : " + e);
+        } catch (InvocationTargetException e) {
+            e.printStackTrace();
         }
         return beanObj;
     }
@@ -82,13 +95,24 @@
      * This will fill the hashmap by getting all the methods in a given class , since it make easier
      * to acess latter
      */
-    private void fillMethods(){
-
-        Field [] fields = beanClass.getDeclaredFields();
-        for (int i = 0; i < fields.length; i++) {
-            Field field = fields[i];
-            this.fields.put(field.getName(),field);
+    private void fillMethods() {
+        try {
+            BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
+            PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
+            for (int i = 0; i < propDescs.length; i++) {
+                PropertyDescriptor field = propDescs[i];
+                this.fields.put(field.getName(), field);
+            }
+        } catch (IntrospectionException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
         }
+
+//
+//        Field [] fields = beanClass.getDeclaredFields();
+//        for (int i = 0; i < fields.length; i++) {
+//            Field field = fields[i];
+//            this.fields.put(field.getName(), field);
+//        }
     }
 
 }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java?rev=326069&r1=326068&r2=326069&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java Tue Oct 18 03:02:28 2005
@@ -78,14 +78,13 @@
             DependencyManager.configureBusinessLogicProvider(obj, inMessage, null);
 
             OperationDescription op = inMessage.getOperationContext().getOperationDescription();
-            if (op == null) {
-                throw new AxisFault(
-                        "Operation is not located, if this is doclit style the SOAP-ACTION should " +
-                                "specified via the SOAP Action to use the RawXMLProvider");
-            }
+
+            OMElement methodElement = inMessage.getEnvelope().getBody()
+                    .getFirstElement();
             String methodName = op.getName().getLocalPart();
             Method[] methods = ImplClass.getMethods();
             //todo method validation has to be done
+            //Todo if we find the method it should be store , in OperationDescription
             for (int i = 0; i < methods.length; i++) {
                 if (methods[i].getName().equals(methodName)) {
                     this.method = methods[i];
@@ -94,39 +93,7 @@
             }
 
 
-            Class[] parameters = method.getParameterTypes();
-            int paracount = 0;
-            int numberofparas = parameters.length;
-
-            Object [] objarray = new Object[numberofparas];
-            OMElement methodElement = inMessage.getEnvelope().getBody()
-                    .getFirstElement();
-            Iterator parts = methodElement.getChildren();
-            /**
-             * Take the number of paramters in the method and , only take that much of child elements
-             * from the OMElement , other are ignore , as an example
-             * if the method is , foo(String a , int b)
-             * and if the OMElemet
-             * <foo>
-             *  <arg0>Val1</arg0>
-             *  <arg1>Val2</arg1>
-             *  <arg2>Val3</arg2>
-             *
-             * only the val1 and Val2 take into account
-             */
-            while (parts.hasNext() && paracount < numberofparas) {
-                OMElement omElement = (OMElement) parts.next();
-                Class parameter = parameters[paracount];
-                Object simpleObj = SimpleTypeMapper.getSimpleTypeObject(parameter, omElement);
-                if (simpleObj != null) {
-                    objarray[paracount] = simpleObj;
-                } else {
-                    //Handle only the JavaBean
-                    simpleObj = new BeanSerializer(parameter, omElement).deserilze();
-                    objarray[paracount] = simpleObj;
-                }
-                paracount ++;
-            }
+            Object[] objarray = processRequest(methodElement);
             Object resObject = method.invoke(obj, objarray);
 
             // Handling the response
@@ -134,36 +101,86 @@
             OMNamespace ns = getSOAPFactory().createOMNamespace(
                     "http://soapenc/", "res");
             SOAPEnvelope envelope = getSOAPFactory().getDefaultEnvelope();
-            OMElement bodyContent = getSOAPFactory().createOMElement(
-                    method.getName() + "Response", ns);
-            if (resObject != null) {
-                //simple type
-                if (SimpleTypeMapper.isSimpleType(resObject)) {
-                    OMElement child = getSOAPFactory().createOMElement(RETURN_WRAPPER, null);
-                    child.addChild(fac.createText(child, resObject.toString()));
-                    bodyContent.addChild(child);
-                } else {
-                    // Java Beans
-                    XMLStreamReader xr = BeanSerializerUtil.getPullParser(resObject,
-                            new QName(RETURN_WRAPPER));
-                    StAXOMBuilder stAXOMBuilder =
-                            OMXMLBuilderFactory.createStAXOMBuilder(
-                                    OMAbstractFactory.getSOAP11Factory(), xr);
-                    OMElement documentElement = stAXOMBuilder.getDocumentElement();
-
-                    if (documentElement != null) {
-                        bodyContent.addChild(documentElement);
-                    }
-                }
-            }
-            if (bodyContent != null) {
-                envelope.getBody().addChild(bodyContent);
-            }
+            OMElement bodyContent = null;
+
+            processResponse(resObject, bodyContent, ns, envelope);
             outMessage.setEnvelope(envelope);
 
         } catch (Exception e) {
             e.printStackTrace();
             throw AxisFault.makeFault(e);
+        }
+    }
+
+    private Object[] processRequest(OMElement methodElement) throws AxisFault {
+        Class[] parameters = method.getParameterTypes();
+        int paracount = 0;
+        int numberofparas = parameters.length;
+
+        Object [] objarray = new Object[numberofparas];
+        Iterator parts = methodElement.getChildren();
+        /**
+         * Take the number of paramters in the method and , only take that much of child elements
+         * from the OMElement , other are ignore , as an example
+         * if the method is , foo(String a , int b)
+         * and if the OMElemet
+         * <foo>
+         *  <arg0>Val1</arg0>
+         *  <arg1>Val2</arg1>
+         *  <arg2>Val3</arg2>
+         *
+         * only the val1 and Val2 take into account
+         */
+        while (parts.hasNext() && paracount < numberofparas) {
+            OMElement omElement = (OMElement) parts.next();
+            Class parameter = parameters[paracount];
+            //todo do we need to support REF and MultiRef
+            //todo firts xsi:type has to be checked , and if that is there take the
+            //todo handle arrays
+            // corret one from sereviceDescription
+            if(OMElement.class.isAssignableFrom(parameter)){
+                objarray[paracount] =omElement;
+            }  else if(SimpleTypeMapper.isSimpleType(parameter)){
+                objarray[paracount]  = SimpleTypeMapper.getSimpleTypeObject(parameter, omElement);
+            } else {
+                objarray[paracount] = new BeanSerializer(parameter, omElement).deserilze();
+            }
+            paracount ++;
+        }
+        return objarray;
+    }
+
+
+
+    private void processResponse(Object resObject, OMElement bodyContent, OMNamespace ns, SOAPEnvelope envelope) {
+        if (resObject != null) {
+            //todo first check to see where the desrilizer for the return object
+            //simple type
+            if(resObject instanceof OMElement){
+                bodyContent = (OMElement)resObject;
+            } else if (SimpleTypeMapper.isSimpleType(resObject)) {
+                bodyContent = getSOAPFactory().createOMElement(
+                        method.getName() + "Response", ns);
+                OMElement child = getSOAPFactory().createOMElement(RETURN_WRAPPER, null);
+                child.addChild(fac.createText(child, SimpleTypeMapper.getStringValue(resObject)));
+                bodyContent.addChild(child);
+            } else {
+                // Java Beans
+                QName wrapperQname = new QName("http://soapenc/", method.getName() + "Response", "res");
+                XMLStreamReader xr = BeanSerializerUtil.getPullParser(resObject,
+                        wrapperQname);
+                StAXOMBuilder stAXOMBuilder =
+                        OMXMLBuilderFactory.createStAXOMBuilder(
+                                OMAbstractFactory.getSOAP11Factory(), xr);
+                OMElement documentElement = stAXOMBuilder.getDocumentElement();
+
+                if (documentElement != null) {
+                    bodyContent = documentElement;
+                }
+            }
+        }
+        if (bodyContent != null) {
+            envelope.getBody().addChild(bodyContent);
         }
     }
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/SimpleTypeMapper.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/SimpleTypeMapper.java?rev=326069&r1=326068&r2=326069&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/SimpleTypeMapper.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/SimpleTypeMapper.java Tue Oct 18 03:02:28 2005
@@ -1,5 +1,7 @@
 package org.apache.axis2.rpc.receivers;
+
 import org.apache.axis2.om.OMElement;
+
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
 *
@@ -43,110 +45,96 @@
     private static final String FLOAT = "float";
     private static final String CHAR = "char";
 
-    public static Object getSimpleTypeObject(Class paramter , OMElement value){
-        if(paramter.getName().equals(STRING)){
+    public static Object getSimpleTypeObject(Class paramter, OMElement value) {
+        if (paramter.getName().equals(STRING)) {
             return value.getText();
-        }   else if (paramter.getName().equals(INT)){
+        } else if (paramter.getName().equals(INT)) {
             return new Integer(value.getText());
-        }    else if (paramter.getName().equals(BOOLEAN)){
+        } else if (paramter.getName().equals(BOOLEAN)) {
             return Boolean.valueOf(value.getText());
-        }   else if (paramter.getName().equals(BYTE)){
+        } else if (paramter.getName().equals(BYTE)) {
             return new Byte(value.getText());
-        }   else if (paramter.getName().equals(DOUBLE)){
+        } else if (paramter.getName().equals(DOUBLE)) {
             return new Double(value.getText());
-        }   else if (paramter.getName().equals(SHORT)){
+        } else if (paramter.getName().equals(SHORT)) {
             return new Short(value.getText());
-        } else if (paramter.getName().equals(LONG)){
+        } else if (paramter.getName().equals(LONG)) {
             return new Long(value.getText());
-        }  else if (paramter.getName().equals(FLOAT)){
+        } else if (paramter.getName().equals(FLOAT)) {
             return new Float(value.getText());
-        }  else if (paramter.getName().equals(CHAR)){
+        } else if (paramter.getName().equals(CHAR)) {
             return new Character(value.getText().toCharArray()[0]);
-        }   else {
+        } else {
             return null;
         }
     }
 
-    public static boolean isSimpleType(Object obj){
-        String objClassName =obj.getClass().getName();
-        if(objClassName.equals(STRING)){
-            return true;
-        }   else if (objClassName.equals(INT)){
-            return true;
-        }    else if (objClassName.equals(BOOLEAN)){
-            return true;
-        }   else if (objClassName.equals(BYTE)){
-            return true;
-        }   else if (objClassName.equals(DOUBLE)){
-            return true;
-        }   else if (objClassName.equals(SHORT)){
-            return true;
-        } else if (objClassName.equals(LONG)){
-            return true;
-        }  else if (objClassName.equals(FLOAT)){
-            return true;
-        }  else if (objClassName.equals(CHAR)){
-            return true;
-        }   else if (objClassName.equals(W_INT)){
-            return true;
-        }    else if (objClassName.equals(W_BOOLEAN)){
-            return true;
-        }   else if (objClassName.equals(W_BYTE)){
-            return true;
-        }   else if (objClassName.equals(W_DOUBLE)){
-            return true;
-        }   else if (objClassName.equals(W_SHORT)){
-            return true;
-        } else if (objClassName.equals(W_LONG)){
-            return true;
-        }  else if (objClassName.equals(W_FLOAT)){
-            return true;
-        }  else if (objClassName.equals(W_CHAR)){
-            return true;
-        }   else {
-            return false;
-        }
+    public static boolean isSimpleType(Object obj) {
+        String objClassName = obj.getClass().getName();
+        return isSimpleType(objClassName);
     }
 
-    public static boolean isSimpleType(Class obj){
-        String objClassName =obj.getName();
-        if(objClassName.equals(STRING)){
-            return true;
-        }   else if (objClassName.equals(INT)){
+
+    public static boolean isSimpleType(Class obj) {
+        String objClassName = obj.getName();
+        return isSimpleType(objClassName);
+    }
+
+    private static boolean isSimpleType(String objClassName) {
+        if (objClassName.equals(STRING)) {
             return true;
-        }    else if (objClassName.equals(BOOLEAN)){
+        } else if (objClassName.equals(INT)) {
             return true;
-        }   else if (objClassName.equals(BYTE)){
+        } else if (objClassName.equals(BOOLEAN)) {
             return true;
-        }   else if (objClassName.equals(DOUBLE)){
+        } else if (objClassName.equals(BYTE)) {
             return true;
-        }   else if (objClassName.equals(SHORT)){
+        } else if (objClassName.equals(DOUBLE)) {
             return true;
-        } else if (objClassName.equals(LONG)){
+        } else if (objClassName.equals(SHORT)) {
             return true;
-        }  else if (objClassName.equals(FLOAT)){
+        } else if (objClassName.equals(LONG)) {
             return true;
-        }  else if (objClassName.equals(CHAR)){
+        } else if (objClassName.equals(FLOAT)) {
             return true;
-        }   else if (objClassName.equals(W_INT)){
+        } else if (objClassName.equals(CHAR)) {
             return true;
-        }    else if (objClassName.equals(W_BOOLEAN)){
+        } else if (objClassName.equals(W_INT)) {
             return true;
-        }   else if (objClassName.equals(W_BYTE)){
+        } else if (objClassName.equals(W_BOOLEAN)) {
             return true;
-        }   else if (objClassName.equals(W_DOUBLE)){
+        } else if (objClassName.equals(W_BYTE)) {
             return true;
-        }   else if (objClassName.equals(W_SHORT)){
+        } else if (objClassName.equals(W_DOUBLE)) {
             return true;
-        } else if (objClassName.equals(W_LONG)){
+        } else if (objClassName.equals(W_SHORT)) {
             return true;
-        }  else if (objClassName.equals(W_FLOAT)){
+        } else if (objClassName.equals(W_LONG)) {
             return true;
-        }  else if (objClassName.equals(W_CHAR)){
+        } else if (objClassName.equals(W_FLOAT)) {
             return true;
-        }   else {
-            return false;
-        }
+        } else return objClassName.equals(W_CHAR);
     }
 
+    public static String getStringValue(Object obj) {
+        if (obj instanceof Float ||
+                obj instanceof Double) {
+            double data;
+            if (obj instanceof Float) {
+                data = ((Float) obj).doubleValue();
+            } else {
+                data = ((Double) obj).doubleValue();
+            }
+            if (Double.isNaN(data)) {
+                return "NaN";
+            } else if (data == Double.POSITIVE_INFINITY) {
+                return "INF";
+            } else if (data == Double.NEGATIVE_INFINITY) {
+                return "-INF";
+            } else {
+                return obj.toString();
+            }
+        }
+        return obj.toString();
+    }
 }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java?rev=326069&r1=326068&r2=326069&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java Tue Oct 18 03:02:28 2005
@@ -6,7 +6,11 @@
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
+import java.beans.PropertyDescriptor;
+import java.beans.Introspector;
+import java.beans.IntrospectionException;
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
 *
@@ -62,4 +66,6 @@
            return null;
         }
     }
+
+
 }

Modified: webservices/axis2/trunk/java/modules/core/test-resources/deployment/service1.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test-resources/deployment/service1.xml?rev=326069&r1=326068&r2=326069&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test-resources/deployment/service1.xml (original)
+++ webservices/axis2/trunk/java/modules/core/test-resources/deployment/service1.xml Tue Oct 18 03:02:28 2005
@@ -8,7 +8,9 @@
 
 
     <!--  Service TypeMapping -->
-    <typeMapping>Type mappping should come here</typeMapping>
+    <typeMapping>
+        <typeMapper xsiType="int" javaType="java.lang.Integer" class="org.apache.axis2.rpc.TypeMapperImpl"/>
+    </typeMapping>
     <beanMapping>bean mappping should come here</beanMapping>
 
     <!--

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/AddressBean.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/AddressBean.java?rev=326069&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/AddressBean.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/AddressBean.java Tue Oct 18 03:02:28 2005
@@ -0,0 +1,48 @@
+package org.apache.axis2.rpc;
+/*
+* 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.
+*
+*
+*/
+
+/**
+ * Author: Deepal Jayasinghe
+ * Date: Oct 12, 2005
+ * Time: 12:03:55 PM
+ */
+public class AddressBean {
+    private String Town;
+    private int number ;
+
+    public String getTown() {
+        return Town;
+    }
+
+    public void setTown(String town) {
+        Town = town;
+    }
+
+    public int getNumber() {
+        return number;
+    }
+
+    public void setNumber(int number) {
+        this.number = number;
+    }
+
+    public String toString(){
+        return ("Town: " + Town + " number :" + number);
+    }
+}

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MyBean.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MyBean.java?rev=326069&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MyBean.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MyBean.java Tue Oct 18 03:02:28 2005
@@ -0,0 +1,66 @@
+package org.apache.axis2.rpc;
+/*
+* 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.
+*
+*
+*/
+
+/**
+ * Author: Deepal Jayasinghe
+ * Date: Oct 12, 2005
+ * Time: 11:24:03 AM
+ */
+public class MyBean {
+    private String Name;
+    private int age;
+    private boolean value;
+    private AddressBean address;
+
+    public String getName() {
+        return Name;
+    }
+
+    public void setName(String name) {
+        Name = name;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public boolean isValue() {
+        return value;
+    }
+
+    public void setValue(boolean value) {
+        this.value = value;
+    }
+
+    public AddressBean getAddress() {
+        return address;
+    }
+
+    public void setAddress(AddressBean address) {
+        this.address = address;
+    }
+
+    public String toString(){
+        return ("Name:" + Name + " Age : " + age + " Value : " + value + " Address : " );
+    }
+}

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java?rev=326069&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java Tue Oct 18 03:02:28 2005
@@ -0,0 +1,305 @@
+package org.apache.axis2.rpc;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.description.ParameterImpl;
+import org.apache.axis2.description.OperationDescription;
+import org.apache.axis2.description.InOutOperationDescrition;
+import org.apache.axis2.integration.UtilServer;
+import org.apache.axis2.receivers.AbstractMessageReceiver;
+import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
+import org.apache.axis2.rpc.receivers.BeanSerializer;
+import org.apache.axis2.rpc.client.RPCCall;
+import org.apache.axis2.rpc.client.RPCRequest;
+import org.apache.axis2.rpc.client.RPCRequestParameter;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.Constants;
+import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.wsdl.WSDLService;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+/*
+* 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.
+*
+*
+*/
+
+/**
+ * Author: Deepal Jayasinghe
+ * Date: Oct 13, 2005
+ * Time: 1:51:02 PM
+ */
+public class RPCCallTest extends TestCase {
+
+    protected EndpointReference targetEPR =
+            new EndpointReference("http://127.0.0.1:"
+                    + (5000)
+//                    + (UtilServer.TESTING_PORT)
+                    + "/axis/services/EchoXMLService/concat");
+    protected Log log = LogFactory.getLog(getClass());
+    protected QName serviceName = new QName("EchoXMLService");
+    protected QName operationName = new QName("http://localhost/my","concat");
+    protected QName transportName = new QName("http://localhost/my",
+            "NullTransport");
+
+    protected AxisConfiguration engineRegistry;
+    protected MessageContext mc;
+    protected ServiceContext serviceContext;
+    protected ServiceDescription service;
+
+    protected boolean finish = false;
+
+    public RPCCallTest() {
+        super(RPCCallTest.class.getName());
+    }
+
+    public RPCCallTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        UtilServer.start();
+//        String className = "org.apache.axis2.rpc.RPCServiceClass";
+//        ServiceDescription service = new ServiceDescription(serviceName);
+//        service.setClassLoader(Thread.currentThread().getContextClassLoader());
+//        service.addParameter( new ParameterImpl(AbstractMessageReceiver.SERVICE_CLASS,
+//                className));
+//        OperationDescription axisOp = new InOutOperationDescrition(operationName);
+//        axisOp.setMessageReceiver(new RPCMessageReceiver());
+//        axisOp.setStyle(WSDLService.STYLE_RPC);
+//        service.addOperation(axisOp);
+//        UtilServer.deployService(service);
+    }
+
+    protected void tearDown() throws Exception {
+        UtilServer.unDeployService(serviceName);
+        UtilServer.stop();
+        UtilServer.unDeployClientService();
+    }
+
+    public void testeditBean() throws AxisFault {
+        configureSystem("editBean");
+        RPCCall call =
+                new RPCCall("target/test-resources/intregrationRepo");
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP,
+                false);
+        MyBean bean = new MyBean();
+        bean.setAge(100);
+        bean.setName("Deepal");
+        bean.setValue(false);
+        AddressBean ab = new AddressBean();
+        ab.setNumber(1010);
+        ab.setTown("Colombo3");
+        bean.setAddress(ab);
+
+
+        ArrayList args = new ArrayList();
+        args.add(bean);
+        args.add("159");
+
+        OMElement response = call.invokeBlocking(operationName,args.toArray());
+        MyBean resBean =(MyBean) new  BeanSerializer(MyBean.class,response).deserilze();
+        assertNotNull(resBean);
+        assertEquals(resBean.getAge(),159);
+        call.close();
+    }
+
+    private void configureSystem(String opName) throws AxisFault {
+        targetEPR =
+                new EndpointReference("http://127.0.0.1:"
+                        + (5000)
+//                    + (UtilServer.TESTING_PORT)
+                        + "/axis/services/EchoXMLService/"+ opName);
+        String className = "org.apache.axis2.rpc.RPCServiceClass";
+        operationName = new QName("http://localhost/my",opName,"req");
+        ServiceDescription service = new ServiceDescription(serviceName);
+        service.setClassLoader(Thread.currentThread().getContextClassLoader());
+        service.addParameter( new ParameterImpl(AbstractMessageReceiver.SERVICE_CLASS,
+                className));
+        OperationDescription axisOp = new InOutOperationDescrition(operationName);
+        axisOp.setMessageReceiver(new RPCMessageReceiver());
+        axisOp.setStyle(WSDLService.STYLE_RPC);
+        service.addOperation(axisOp);
+        UtilServer.deployService(service);
+    }
+
+    public void testechoBean() throws AxisFault {
+        configureSystem("echoBean");
+        RPCCall call =
+                new RPCCall("target/test-resources/intregrationRepo");
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP,
+                false);
+
+        MyBean bean = new MyBean();
+        bean.setAge(100);
+        bean.setName("Deepal");
+        bean.setValue(false);
+        AddressBean ab = new AddressBean();
+        ab.setNumber(1010);
+        ab.setTown("Colombo3");
+        bean.setAddress(ab);
+
+        ArrayList args = new ArrayList();
+        args.add(bean);
+
+
+        OMElement response = call.invokeBlocking(operationName,args.toArray());
+        MyBean resBean =(MyBean) new  BeanSerializer(MyBean.class,response).deserilze();
+        assertNotNull(resBean);
+        assertEquals(resBean.getAge(),100);
+        call.close();
+    }
+
+
+    public void testechoString() throws AxisFault {
+        configureSystem("echoString");
+        RPCCall call =
+                new RPCCall("target/test-resources/intregrationRepo");
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP,
+                false);
+
+        ArrayList args = new ArrayList();
+        args.add("foo");
+        OMElement response = call.invokeBlocking(operationName,args.toArray());
+        assertEquals(response.getFirstElement().getText(),"foo");
+        call.close();
+    }
+
+    public void testechoInt() throws AxisFault {
+        configureSystem("echoInt");
+        RPCCall call =
+                new RPCCall("target/test-resources/intregrationRepo");
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP,
+                false);
+
+        ArrayList args = new ArrayList();
+        args.add("100");
+
+        OMElement response = call.invokeBlocking(operationName,args.toArray());
+        assertEquals(Integer.parseInt(response.getFirstElement().getText()),100);
+        call.close();
+    }
+
+    public void testadd() throws AxisFault {
+        configureSystem("add");
+        RPCCall call =
+                new RPCCall("target/test-resources/intregrationRepo");
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP,
+                false);
+        ArrayList args = new ArrayList();
+        args.add("100");
+        args.add("200");
+
+        OMElement response = call.invokeBlocking(operationName,args.toArray());
+        assertEquals(Integer.parseInt(response.getFirstElement().getText()),300);
+        call.close();
+    }
+
+    public void testdivide() throws AxisFault {
+        configureSystem("divide");
+        RPCCall call =
+                new RPCCall("target/test-resources/intregrationRepo");
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP,
+                false);
+
+        ArrayList args = new ArrayList();
+        args.add("10");
+        args.add("0");
+        OMElement response = call.invokeBlocking(operationName,args.toArray());
+        assertEquals(response.getFirstElement().getText(),"INF");
+        call.close();
+    }
+
+    public void testechoBool() throws AxisFault {
+        configureSystem("echoBool");
+        RPCCall call =
+                new RPCCall("target/test-resources/intregrationRepo");
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP,
+                false);
+
+
+        ArrayList args = new ArrayList();
+        args.add("true");
+
+        OMElement response = call.invokeBlocking(operationName,args.toArray());
+        assertEquals(Boolean.valueOf(response.getFirstElement().getText()).booleanValue(),true);
+        call.close();
+    }
+
+    public void testechoByte() throws AxisFault {
+        configureSystem("echoByte");
+        RPCCall call =
+                new RPCCall("target/test-resources/intregrationRepo");
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP,
+                false);
+
+        ArrayList args = new ArrayList();
+        args.add("1");
+        OMElement response = call.invokeBlocking(operationName,args.toArray());
+        assertEquals(Byte.parseByte(response.getFirstElement().getText()),1);
+        call.close();
+    }
+
+    public void testechoOM() throws AxisFault {
+        configureSystem("echoOM");
+        RPCCall call =
+                new RPCCall("target/test-resources/intregrationRepo");
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP,
+                false);
+
+        ArrayList args = new ArrayList();
+        args.add("1");
+        OMElement response = call.invokeBlocking(operationName,args.toArray());
+        assertEquals(Byte.parseByte(response.getFirstElement().getText()),1);
+        call.close();
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java?rev=326069&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java Tue Oct 18 03:02:28 2005
@@ -0,0 +1,74 @@
+package org.apache.axis2.rpc;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.soap.SOAPFactory;
+
+import javax.xml.namespace.QName;
+/*
+* 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.
+*
+*
+*/
+
+/**
+ * Author: Deepal Jayasinghe
+ * Date: Oct 11, 2005
+ * Time: 10:29:05 PM
+ */
+public class RPCServiceClass {
+
+    public MyBean editBean(MyBean bean , int a){
+        bean.setAge(a);
+        return bean;
+    }
+
+    public MyBean echoBean(MyBean bean){
+        return bean;
+    }
+
+    public String echoString(String in){
+        return in;
+    }
+
+    public int echoInt(int i){
+        return i;
+    }
+
+    public int add(int a , int b){
+        return a+b;
+    }
+
+    public boolean echoBool(boolean b){
+        return b;
+    }
+
+    public byte echoByte(byte b){
+        return b;
+    }
+    public OMElement echoOM(OMElement b){
+        SOAPFactory fac =   OMAbstractFactory.getSOAP12Factory();
+        OMNamespace ns = fac.createOMNamespace(
+                "http://soapenc/", "res");
+        OMElement bodyContent = fac.createOMElement(new QName("echoOM") + "Response", ns);
+        bodyContent.addChild(b);
+        return bodyContent;
+    }
+
+    public double divide(double a , double b){
+       return (a/b);
+    }
+}