axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r327114 - 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/ integration/test/org/apache/axis2/rpc/
Date Fri, 21 Oct 2005 07:13:48 GMT
Author: deepal
Date: Fri Oct 21 00:13:27 2005
New Revision: 327114

URL: http://svn.apache.org/viewcvs?rev=327114&view=rev
Log:
If some service class want to return multiple objects (Java does not allow that) , Axis1 has
concept of holder. 
But if service class want to return multiple object he can do that by creating Object array
by putting all those object and return that
and our RPCMessageReceiver will serialize that into multiple parts and send to the client.


Modified:
    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/receivers/RPCMessageReceiver.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.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/client/RPCCall.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCCall.java?rev=327114&r1=327113&r2=327114&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCCall.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/client/RPCCall.java
Fri Oct 21 00:13:27 2005
@@ -91,7 +91,7 @@
         opDesc = createOpDescAndFillInFlowInformation(opDesc, opName.getLocalPart(),
                 WSDLConstants.MEP_CONSTANT_IN_OUT);
         opDesc.setParent(serviceContext.getServiceConfig());
-        MessageContext msgctx = prepareTheSOAPEnvelope(getOMElement(opName,args));
+        MessageContext msgctx = prepareTheSOAPEnvelope(BeanSerializerUtil.getOMElement(opName,args));
 
         this.lastResponseMessage = super.invokeBlocking(opDesc, msgctx);
         SOAPEnvelope resEnvelope = lastResponseMessage.getEnvelope();
@@ -121,7 +121,7 @@
         opDesc = createOpDescAndFillInFlowInformation(opDesc, opName.getLocalPart(),
                 WSDLConstants.MEP_CONSTANT_IN_OUT);
         opDesc.setParent(serviceContext.getServiceConfig());
-        MessageContext msgctx = prepareTheSOAPEnvelope(getOMElement(opName,args));
+        MessageContext msgctx = prepareTheSOAPEnvelope(BeanSerializerUtil.getOMElement(opName,args));
         this.lastResponseMessage = super.invokeBlocking(opDesc, msgctx);
         SOAPEnvelope resEnvelope = lastResponseMessage.getEnvelope();
         return BeanSerializerUtil.deserialize(resEnvelope.getBody().getFirstElement(),returnTypes);
@@ -145,7 +145,7 @@
         OperationDescription opDesc =
                 serviceContext.getServiceConfig().getOperation(opName);
         opDesc = createOpDescAndFillInFlowInformation(opDesc, opName.getLocalPart(), WSDLConstants.MEP_CONSTANT_IN_OUT);
-        MessageContext msgctx = prepareTheSOAPEnvelope(getOMElement(opName,args));
+        MessageContext msgctx = prepareTheSOAPEnvelope(BeanSerializerUtil.getOMElement(opName,args));
         //call the underline implementation
         super.invokeNonBlocking(opDesc, msgctx, callback);
     }
@@ -157,29 +157,6 @@
      * @param opName
      * @param args
      */
-    private OMElement getOMElement(QName opName ,Object [] args) {
-        ArrayList objects ;
-        objects = new ArrayList();
-        int argCount =0;
-        for (int i = 0; i < args.length; i++) {
-            Object arg = args[i];
-            //todo if the request paramter has name other than argi (0<i<n) , there
should be a
-            //was to do that , to solve that problem we need to have RPCRequestParameter
-            //note that The value of request paramter can either be simple type or JavaBean
-            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();
-    }
+
 
 }

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=327114&r1=327113&r2=327114&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
Fri Oct 21 00:13:27 2005
@@ -102,7 +102,14 @@
             SOAPEnvelope envelope = getSOAPFactory().getDefaultEnvelope();
             OMElement bodyContent = null;
 
-            processResponse(resObject, bodyContent, ns, envelope);
+            if(resObject instanceof Object[]){
+                QName resName = new QName("http://soapenc/",  method.getName() + "Response",
"res");
+                OMElement bodyChild = getResponseElement(resName,(Object[])resObject);
+                envelope.getBody().addChild(bodyChild);
+            }   else {
+                processResponse(resObject, bodyContent, ns, envelope);
+            }
+
             outMessage.setEnvelope(envelope);
 
         } catch (Exception e) {
@@ -116,7 +123,9 @@
         return   BeanSerializerUtil.deserialize(methodElement,parameters);
     }
 
-
+    private OMElement getResponseElement(QName resname, Object [] objs){
+        return BeanSerializerUtil.getOMElement(resname,objs);
+    }
 
     private void processResponse(Object resObject, OMElement bodyContent, OMNamespace ns,
SOAPEnvelope envelope) {
         if (resObject != null) {

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=327114&r1=327113&r2=327114&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
Fri Oct 21 00:13:27 2005
@@ -5,6 +5,9 @@
 import org.apache.axis2.databinding.utils.ADBPullParser;
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMAttribute;
+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.AxisFault;
 
 import javax.xml.namespace.QName;
@@ -150,7 +153,7 @@
                         String refId = MultirefHelper.getAttvalue(attr);
                         partObj =  helper.getObject(refId);
                         if(partObj == null){
-                           partObj = helper.processRef(parameters,refId);
+                            partObj = helper.processRef(parameters,refId);
                         }
                     } else {
                         partObj = SimpleTypeMapper.getSimpleTypeObject(parameters, parts);
@@ -261,6 +264,29 @@
         return  retObjs;
     }
 
-
+    public static OMElement getOMElement(QName opName ,Object [] args) {
+        ArrayList objects ;
+        objects = new ArrayList();
+        int argCount =0;
+        for (int i = 0; i < args.length; i++) {
+            Object arg = args[i];
+            //todo if the request paramter has name other than argi (0<i<n) , there
should be a
+            //was to do that , to solve that problem we need to have RPCRequestParameter
+            //note that The value of request paramter can either be simple type or JavaBean
+            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();
+    }
 
 }

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java?rev=327114&r1=327113&r2=327114&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
Fri Oct 21 00:13:27 2005
@@ -177,6 +177,39 @@
         assertEquals(env.getBody().getFirstElement().getFirstElement().getText(), "20");
     }
 
+     public void testaddSameRef() throws AxisFault {
+        configureSystem("add");
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+
+        OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+        OMElement method = fac.createOMElement("add", omNs);
+        OMElement value = fac.createOMElement("arg0", null);
+        value.addAttribute(fac.createOMAttribute("href",null,"#1"));
+        method.addChild(value);
+
+        OMElement value2 = fac.createOMElement("arg1", null);
+        value2.addAttribute(fac.createOMAttribute("href",null,"#1"));
+        method.addChild(value2);
+
+        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+        SOAPEnvelope envelope = factory.getDefaultEnvelope();
+        envelope.getBody().addChild(method);
+
+        OMElement ref = fac.createOMElement("reference", null);
+        ref.addAttribute(fac.createOMAttribute("id",null,"1"));
+        ref.setText("10");
+        envelope.getBody().addChild(ref);
+        RPCCall call =
+                new RPCCall("target/test-resources/intregrationRepo");
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP,
+                false);
+        SOAPEnvelope env = call.invokeBlocking("add",envelope);
+        assertEquals(env.getBody().getFirstElement().getFirstElement().getText(), "20");
+    }
+
     public void testaddError() {
         try {
             configureSystem("add");

Modified: 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=327114&r1=327113&r2=327114&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
Fri Oct 21 00:13:27 2005
@@ -395,4 +395,24 @@
         call.close();
     }
 
+     public void testmulReturn() throws AxisFault {
+        configureSystem("mulReturn");
+        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();
+    }
+
 }

Modified: 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=327114&r1=327113&r2=327114&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java
Fri Oct 21 00:13:27 2005
@@ -12,6 +12,7 @@
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
 import java.util.Calendar;
+import java.util.ArrayList;
 import java.io.ByteArrayInputStream;
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
@@ -100,5 +101,27 @@
                 fac.createText(value2, "foo"));
         method.addChild(value2);
         return   method;
+    }
+
+
+    /**
+     * This methods return mutiple object , so it creat an Object array and retuen that
+     * so , if a method want to return mutiple value , this way can be used
+     * @param obj
+     * @return Object []
+     */
+    public Object[] mulReturn(OMElement obj){
+        ArrayList objs= new ArrayList();
+        objs.add(new Integer(100));
+        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);
+        objs.add(bean);
+        return objs.toArray();
     }
 }



Mime
View raw message