You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/06/22 21:58:07 UTC

svn commit: r192988 [2/2] - in /incubator/beehive/trunk: system-controls/test/src/webservice/ system-controls/test/src/webservice/schemas/ system-controls/test/src/webservice/servers/webapp/WEB-INF/webservices/soapMarshalling/ system-controls/test/src/...

Modified: incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitBareTest.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitBareTest.java?rev=192988&r1=192987&r2=192988&view=diff
==============================================================================
--- incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitBareTest.java (original)
+++ incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitBareTest.java Wed Jun 22 12:58:06 2005
@@ -28,17 +28,12 @@
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 
-// @todo: ALL TESTS FAIL
 public class SoapMarshallingDocLitBareTest
         extends ControlTestCase {
 
     @Control
     public SoapMarshallingDocLitBareService client;
 
-    public void test_ALL_TESTS_FAIL() {
-
-    }
-/*
         public void testEchoboolean() throws Exception {
             assertFalse(client.echoboolean(false));
             assertTrue(client.echoboolean(true));
@@ -109,41 +104,54 @@
             assertEquals("Hello World!", client.echoString("Hello World!"));
         }
 
-        public void testEchoGregorianCalendar() throws Exception {
-            soapMarshalling.GregorianCalendar sgcal = soapMarshalling.GregorianCalendar.Factory.newInstance();
-            sgcal.setTimeInMillis(123456789);
-            assertTrue(sgcal.compareTo(client.echoGregorianCalendar(sgcal)) == 0);
-        }
-
-        public void testEchoDate() throws Exception {
-            Calendar cal = new GregorianCalendar();
-            cal.setTimeInMillis(123456789);
-            assertTrue(cal.equals(client.echoDate(cal)));
-        }
-
-        public void testEchoCalendar() throws Exception {
-            Calendar cal = new GregorianCalendar();
-            cal.setTimeInMillis(123456789);
-            assertTrue(cal.equals(client.echoCalendar(cal)));
-        }
-
-        public void testEchoGDate() throws Exception {
-            soapMarshalling.GDate gdate = soapMarshalling.GDate.Factory.newInstance();
-            gdate.setYear(2005);
-            assertTrue(gdate.compareTo(client.echoGDate(gdate)) == 0);
-        }
-
-        public void testEchoGDuration() throws Exception {
-            soapMarshalling.GDuration gdur = soapMarshalling.GDuration.Factory.newInstance();
-            gdur.setYear(2006);
-            assertTrue(gdur.compareTo(client.echoGDuration(gdur)) == 0);
-        }
+// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// The following tests fail due to an AXIS or WSM bug.  The java.util.Calendar class fails during Serialization
+// on the server. Logged in JIRA as BEEHIVE-817
+// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+//        public void testEchoGregorianCalendar() throws Exception {
+//            soapMarshalling.GregorianCalendar sgcal = soapMarshalling.GregorianCalendar.Factory.newInstance();
+//            sgcal.setTimeInMillis(123456789);
+//            assertTrue(sgcal.compareTo(client.echoGregorianCalendar(sgcal)) == 0);
+//        }
+
+//        public void testEchoDate() throws Exception {
+//            Calendar cal = new GregorianCalendar();
+//            cal.setTimeInMillis(123456789);
+//            assertTrue(cal.equals(client.echoDate(cal)));
+//        }
+
+//        public void testEchoCalendar() throws Exception {
+//            Calendar cal = new GregorianCalendar();
+//            cal.setTimeInMillis(123456789);
+//            assertTrue(cal.equals(client.echoCalendar(cal)));
+//        }
+
+//        public void testEchoGDate() throws Exception {
+//            soapMarshalling.GDate gdate = soapMarshalling.GDate.Factory.newInstance();
+//            gdate.setYear(2005);
+//            assertTrue(gdate.compareTo(client.echoGDate(gdate)) == 0);
+//        }
+
+//        public void testEchoGDuration() throws Exception {
+//            soapMarshalling.GDuration gdur = soapMarshalling.GDuration.Factory.newInstance();
+//            gdur.setYear(2006);
+//            assertTrue(gdur.compareTo(client.echoGDuration(gdur)) == 0);
+//        }
+
+// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// end failing tests
+// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
         public void testEchoQName() throws Exception {
             QName qname = new QName("http://foo.bar", "foofoo");
             assertEquals(qname.toString(), client.echoQName(qname).toString());
         }
-    */
+
     public void setUp() throws Exception {
         try {
             super.setUp();

Modified: incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitWrappedArrayTypesTest.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitWrappedArrayTypesTest.java?rev=192988&r1=192987&r2=192988&view=diff
==============================================================================
--- incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitWrappedArrayTypesTest.java (original)
+++ incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitWrappedArrayTypesTest.java Wed Jun 22 12:58:06 2005
@@ -94,7 +94,6 @@
 //        assertEquals(array, client.echoLong(array));
 //    }
 
-// @todo: fails
     public void testEchoBigIntegerArray() throws Exception {
         BigInteger[] array = new BigInteger[] {BigInteger.TEN, BigInteger.ONE, BigInteger.TEN};
         assertTrue(Arrays.equals(array, client.echoBigInteger(array)));

Modified: incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitWrappedTest.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitWrappedTest.java?rev=192988&r1=192987&r2=192988&view=diff
==============================================================================
--- incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitWrappedTest.java (original)
+++ incubator/beehive/trunk/system-controls/test/src/webservice/tests/org/apache/beehive/controls/system/webservice/units/SoapMarshallingDocLitWrappedTest.java Wed Jun 22 12:58:06 2005
@@ -110,7 +110,7 @@
 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // The following tests fail due to an AXIS or WSM bug.  The java.util.Calendar class fails during Serialization
-// on the server.
+// on the server. Logged in JIRA as BEEHIVE-817
 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
 

Modified: incubator/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java?rev=192988&r1=192987&r2=192988&view=diff
==============================================================================
--- incubator/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java (original)
+++ incubator/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java Wed Jun 22 12:58:06 2005
@@ -74,10 +74,11 @@
 
     /* declared to prevent no-args construction */
     private XmlBeanWSDLProcessor() {
+        super();
     }
 
     public XmlBeanWSDLProcessor(DefinitionsDocument defDoc, BindingLookupService lookupService) {
-        super();
+        this();
         this.defDoc = defDoc;
         this.lookupService = lookupService;
     }
@@ -122,7 +123,7 @@
             }
 
             for(TOperation op : operations) {
-                processTOperation(op, wsm, methodMap, messageMap, tBind, types);
+                processTOperation(op, wsm, methodMap, messageMap, types);
             }
         }
 
@@ -136,7 +137,6 @@
                                    BeehiveWsTypeMetadata wsm,
                                    Map<String, BeehiveWsMethodMetadata> methodMap,
                                    Map<String, TPart[]> messageMap,
-                                   TBinding tBind,
                                    TTypes types)
         throws Exception {
         String opName = op.getName();
@@ -148,7 +148,7 @@
         if(null != outputParam) {
             TPart[] messageParts = messageMap.get(outputParam.getMessage().getLocalPart());
             // output parameters are not wrapped
-            paraMeta = processParameters(opName, messageParts, tBind, types, messageMap, wsm, true);
+            paraMeta = processParameters(opName, messageParts, types, wsm, true);
         }
         Class returnType;
         QName returnXMLType;
@@ -170,7 +170,6 @@
             returnXMLType = null;
             if(paraMeta.length > 1) {
                 outParamMap = new HashMap<String, BeehiveWsParameterMetadata>(paraMeta.length);
-                boolean returnIsSet = false;
                 for(BeehiveWsParameterMetadata cpm : paraMeta) {
                     outParamMap.put(cpm.getWpName(), cpm);
                 }
@@ -199,12 +198,11 @@
         if(inputParam != null) {
             TPart[] messageParts = messageMap.get(inputParam.getMessage().getLocalPart());
 
-            BeehiveWsParameterMetadata[] params =
-                processParameters(opName, messageParts, tBind, types, messageMap, wsm, false);
+            BeehiveWsParameterMetadata[] params = processParameters(opName, messageParts, types, wsm, false);
 
             if(paramOrder != null) {
-                // Paramorder is only used for rpc.  if there is a paramoder then order the parameters,
-                // remove all the in/out parameters from the out map
+                // Paramorder is only used for rpc AND doc/lit/bare.  if there is a paramoder then order
+                // the parameters, remove all the in/out parameters from the out map
                 for(Object ord : paramOrder) {
                     for(BeehiveWsParameterMetadata wpm : params) {
                         if(ord.equals(wpm.getWpName())) {
@@ -269,9 +267,7 @@
 
     private BeehiveWsParameterMetadata[] processParameters(String operationName,
                                                            TPart[] messageParts,
-                                                           TBinding tBind,
                                                            TTypes types,
-                                                           Map<String, TPart[]> messageMap,
                                                            BeehiveWsTypeMetadata wsm,
                                                            boolean isOutputParameters) {
 
@@ -284,12 +280,11 @@
         // name should be the same as the name of the opeartion.
         boolean paramStyleIsSet = false;
 
-        boolean shouldUnwrap;
-
         if(isOutputParameters) {
             paramStyleIsSet = true;  // only set this for input parameters
         }
-        shouldUnwrap = isWrapped(operationName, messageParts, tBind, isOutputParameters);
+
+        final boolean shouldUnwrap = isWrapped(operationName, messageParts, isOutputParameters);
 
         List<BeehiveWsParameterMetadata> paramList = new ArrayList<BeehiveWsParameterMetadata>(messageParts.length);
         for(TPart messagePart : messageParts) {
@@ -313,10 +308,14 @@
                     unwrapMessagePart(operationName, isOutputParameters, messagePart) // when we do want to unwrap, we should only unwrap the parts the parameters
                     // the parts that are for headers, for instance, should remain intact.
                     ) {
-                    if(!isOutputParameters) {// only set the mode if this is input parameters
-                        wsm.getSoapBinding().setParameterStyle(SOAPBinding.ParameterStyle.WRAPPED);
+
+                    // only set the mode if this is input parameters
+                    if(!isOutputParameters) {
+                        wsm.getSoapBinding().setParameterStyle(getParameterStyle(operationName, isOutputParameters,
+                                                                                 messagePart.getName()));
                         paramStyleIsSet = true;
                     }
+
                     if(types != null) { // if there are some type
                         try {
                             Schema[] schemas = selectChildren(types, Schema.class);
@@ -337,20 +336,43 @@
                                         * complextype   only  has name and type is defined as
                                         * <complexType> child
                                         */
-                                        paramList.add(elementToParamMetaData(s
-                                            .getTargetNamespace(), e));
+                                        paramList.add(elementToParamMetaData(s.getTargetNamespace(), e));
                                     }
                                     else {
                                         // we have <element name=xxx> and its child must be comlexType, or somethig is wrong
-                                        ComplexType ct = e.getComplexType();
-                                        if(ct != null && ct.isSetSequence()) {
-                                            // DOC/LIT WSDL
-                                            /* NOTE: There may be other groupings that this code needs
-                                            * to understand also.  At this point we expect: <element name="xxx" type="yyy">
-                                            * or <element ref="zzz">
-                                            */
-                                            Group g = ct.getSequence();
-                                            for(Element el : g.getElementArray()) {
+                                        final ComplexType ct = e.getComplexType();
+                                        assert ct != null : "Expected complex type!!";
+                                        assert ct.isSetSequence() == true : "Expected sequence structure!!!";
+
+                                        // todo: not handling <complexContent>, sequence may be null if in the form
+                                        // todo: of <sequence/>
+                                        Group g = ct.getSequence();
+                                        Element[] els = null;
+                                        if (g != null) {
+                                            els = ct.getSequence().getElementArray();
+                                        }
+                                        boolean paramAdded = false;
+
+                                        // in the case of bare parameters if the complex object is an array
+                                        // type, set the name of the parameter to the name of the element containing the
+                                        // complex type.
+                                        if (getParameterStyle(operationName, isOutputParameters, messagePart.getName())
+                                                == SOAPBinding.ParameterStyle.BARE  )
+                                        {
+                                            // doc / lit / bare
+                                            if (els != null && els.length == 1) {
+                                                BeehiveWsParameterMetadata  pm = elementToParamMetaData(s.getTargetNamespace(), els[0]);
+                                                if (pm.getJavaType().isArray()) {
+                                                    pm.setWpName(e.getName());
+                                                    paramList.add(pm);
+                                                    paramAdded = true;
+                                                }
+                                            }
+                                        }
+
+                                        if (!paramAdded && els != null) {
+                                            // doc / lit / wrapped
+                                            for(Element el : els) {
                                                 paramList.add(elementToParamMetaData(s.getTargetNamespace(), el));
                                             }
                                         }
@@ -413,7 +435,7 @@
     // if a part is on the header or is a MIME.  The header and MIME parts should not effect the wrapped
     // determination.
     // TODO: the logic here may not work with MIME types, verify later.
-    private boolean isWrapped(String operationName, TPart[] messagePart, TBinding tBind, boolean isOutputParameters) {
+    private boolean isWrapped(String operationName, TPart[] messagePart, boolean isOutputParameters) {
         for(TPart message : messagePart) {
             if(!message.isSetElement()) return false;  // RPC-Encoded
             if(true == unwrapMessagePart(operationName, isOutputParameters, message)) return true;
@@ -436,6 +458,33 @@
         }
 
         return false;
+    }
+
+    /**
+     * Get the SOAP parameter style for the specified operation.  If the operationName matches the
+     * messagePartName bare parameter style is detected.
+     *
+     * @param operationName Name of the operation to check.
+     * @param outputParam Is this an output parameter
+     * @param messagePartName The message part name.
+     * @return BARE or WRAPPED
+     */
+    private SOAPBinding.ParameterStyle getParameterStyle(String operationName, boolean outputParam, String messagePartName) {
+
+        assert messagePartName != null : "Invalid message part name!!!";
+
+        if(outputParam) {
+            if (messagePartName.equals(operationName + "Response")) {
+                return SOAPBinding.ParameterStyle.BARE;
+            }
+        } else {
+            if (messagePartName.equals(operationName)) {
+                return SOAPBinding.ParameterStyle.BARE;
+            }
+        }
+
+        // otherwise default to wrapped
+        return SOAPBinding.ParameterStyle.WRAPPED;
     }
 
     /**