axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/nested Nested2BindingImpl.java Nested2ServiceTestCase.java
Date Sun, 18 Aug 2002 14:19:50 GMT
gdaniels    2002/08/18 07:19:50

  Modified:    java/src/org/apache/axis AxisProperties.java Constants.java
               java/src/org/apache/axis/encoding
                        DefaultTypeMappingImpl.java
               java/src/org/apache/axis/encoding/ser BeanDeserializer.java
                        BeanSerializer.java
               java/src/org/apache/axis/message MessageElement.java
               java/src/org/apache/axis/wsdl/symbolTable SymbolTable.java
               java/src/org/apache/axis/wsdl/toJava JavaBeanWriter.java
               java/test/wsdl/extensibility
                        ExtensibilityQueryBindingImpl.java
                        ExtensibilityQueryTestCase.java
               java/test/wsdl/nested Nested2BindingImpl.java
                        Nested2ServiceTestCase.java
  Log:
  Updates to xsd:any support to handle multiple elements.
  
  1) The bean field for any content is now an array of MessageElements.
      It is called "_any" to avoid conflicts with any names created by
     WSDL2Java (which will javaify things, so no underscores).  This
     means we can now support a) multiple any elements, and b)
     controlling the QName of the XML which gets emitted, both of
     which are important.
  
     See ExtensibilityQueryTestCase/Nested2BindingImpl for examples
     of usage.
  
  2) Add a (QName, Object) constructor for MessageElements with
     Object values.  Before we couldn't differentiate a call like:
     new MessageElement("ns", "localpart", "string value") from
     new MessageElement("ns", "prefix", "localpart").
  
  3) Usual bits of cleanup.
  
  Revision  Changes    Path
  1.10      +0 -1      xml-axis/java/src/org/apache/axis/AxisProperties.java
  
  Index: AxisProperties.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisProperties.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AxisProperties.java	16 Aug 2002 22:51:21 -0000	1.9
  +++ AxisProperties.java	18 Aug 2002 14:19:49 -0000	1.10
  @@ -64,7 +64,6 @@
   import org.apache.commons.discovery.DiscoverClass;
   import org.apache.commons.discovery.DiscoveryException;
   import org.apache.commons.discovery.base.Environment;
  -import org.apache.commons.discovery.base.ImplClass;
   import org.apache.commons.discovery.base.SPInterface;
   import org.apache.commons.discovery.tools.ManagedProperties;
   
  
  
  
  1.82      +1 -1      xml-axis/java/src/org/apache/axis/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- Constants.java	16 Aug 2002 20:07:55 -0000	1.81
  +++ Constants.java	18 Aug 2002 14:19:49 -0000	1.82
  @@ -111,7 +111,7 @@
       public static final String ENTERPRISE_LOG_CATEGORY = "org.apache.axis.enterprise";
   
       /** The name of the field which accepts xsd:any content in Beans */
  -    public static final String ANYCONTENT = "any";
  +    public static final String ANYCONTENT = "_any";
   
       /**
        * Returns true if SOAP_ENV Namespace
  
  
  
  1.47      +0 -6      xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
  
  Index: DefaultTypeMappingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- DefaultTypeMappingImpl.java	16 Aug 2002 20:07:55 -0000	1.46
  +++ DefaultTypeMappingImpl.java	18 Aug 2002 14:19:50 -0000	1.47
  @@ -276,12 +276,6 @@
           myRegister(Constants.XSD_ANYTYPE,    java.lang.Object.class,
                      null, null, false);
   
  -//        // This is the special type for the xsd:any element used for
  -//        // extensibility.
  -//        myRegister(Constants.XSD_ANY,    org.w3c.dom.Element.class,
  -//                   new ElementSerializerFactory(),
  -//                   new ElementDeserializerFactory(), false);
  -
           // See the SchemaVersion classes for where the registration of
           // dateTime (for 2001) and timeInstant (for 1999 & 2000) happen.
           myRegister(Constants.XSD_DATE,       java.util.Date.class,
  
  
  
  1.47      +20 -13    xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java
  
  Index: BeanDeserializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- BeanDeserializer.java	16 Aug 2002 16:06:02 -0000	1.46
  +++ BeanDeserializer.java	18 Aug 2002 14:19:50 -0000	1.47
  @@ -54,7 +54,6 @@
   
   package org.apache.axis.encoding.ser;
   
  -import org.apache.axis.MessageContext;
   import org.apache.axis.Constants;
   import org.apache.axis.description.TypeDesc;
   import org.apache.axis.encoding.DeserializationContext;
  @@ -62,6 +61,7 @@
   import org.apache.axis.encoding.DeserializerImpl;
   import org.apache.axis.encoding.TypeMapping;
   import org.apache.axis.message.SOAPHandler;
  +import org.apache.axis.message.MessageElement;
   import org.apache.axis.utils.BeanPropertyDescriptor;
   import org.apache.axis.utils.JavaUtils;
   
  @@ -191,7 +191,6 @@
           QName elemQName = new QName(namespace, localName);
           // The collectionIndex needs to be reset for Beans with multiple arrays
           if ((prevQName == null) || (!prevQName.equals(elemQName))) {
  -            prevQName = elemQName;
               collectionIndex = -1;
           }  
           prevQName = elemQName;
  @@ -213,22 +212,30 @@
           // reporting a problem
           QName qn = null;
           Deserializer dSer = null;
  -        MessageContext messageContext = context.getMessageContext();
           if (propDesc == null) {
               // try to put unknown elements into a SOAPElement property, if
               // appropriate
               propDesc = getAnyPropertyDesc();
               if (propDesc != null) {
  -                dSer = context.getDeserializerForType(elemQName);
  -                if (dSer == null)  {
  -                    qn = Constants.XSD_ANY;
  -                    // make sure that the Element Deserializer deserializes
  -                    // the current element and not the child
  -                    messageContext.setProperty(ElementDeserializer.
  -                                                    DESERIALIZE_CURRENT_ELEMENT,
  -                                               Boolean.TRUE);
  -                } else {
  -                    qn = elemQName;
  +                try {
  +                    MessageElement [] curElements = (MessageElement[])propDesc.get(value);
  +                    int length = 0;
  +                    if (curElements != null) {
  +                        length = curElements.length;
  +                    }
  +                    MessageElement [] newElements = new MessageElement[length + 1];
  +                    if (curElements != null) {
  +                        System.arraycopy(curElements, 0,
  +                                         newElements, 0, length);
  +                    }
  +                    MessageElement thisEl = context.getCurElement();
  +
  +                    newElements[length] = thisEl;
  +                    propDesc.set(value, newElements);
  +
  +                    return new SOAPHandler();
  +                } catch (Exception e) {
  +                    throw new SAXException(e);
                   }
               }
           }
  
  
  
  1.51      +9 -7      xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
  
  Index: BeanSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- BeanSerializer.java	16 Aug 2002 11:07:09 -0000	1.50
  +++ BeanSerializer.java	18 Aug 2002 14:19:50 -0000	1.51
  @@ -57,6 +57,7 @@
   
   import org.apache.axis.AxisFault;
   import org.apache.axis.Constants;
  +import org.apache.axis.message.MessageElement;
   import org.apache.axis.description.FieldDesc;
   import org.apache.axis.description.TypeDesc;
   import org.apache.axis.encoding.SerializationContext;
  @@ -236,14 +237,15 @@
               BeanPropertyDescriptor anyDesc = typeDesc == null ? null :
                       typeDesc.getAnyDesc();
               if (anyDesc != null) {
  -                // If we have "extra" content here, get the value and serialize
  -                // it with the element name matching the type name for now.
  +                // If we have "extra" content here, it'll be an array
  +                // of MessageElements.  Serialize each one.
                   Object anyVal = anyDesc.get(value);
  -                if (anyVal != null) {
  -                    QName typeQName = context.getQNameForClass(anyVal.getClass());
  -                    context.serialize(typeQName, null,
  -                                      anyVal, typeQName,
  -                                      false, Boolean.TRUE);
  +                if (anyVal != null && anyVal instanceof MessageElement[]) {
  +                    MessageElement [] anyContent = (MessageElement[])anyVal;
  +                    for (int i = 0; i < anyContent.length; i++) {
  +                        MessageElement element = anyContent[i];
  +                        element.output(context);
  +                    }
                   }
               }
           } catch (InvocationTargetException ite) {
  
  
  
  1.120     +7 -1      xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.119
  retrieving revision 1.120
  diff -u -r1.119 -r1.120
  --- MessageElement.java	3 Aug 2002 21:25:25 -0000	1.119
  +++ MessageElement.java	18 Aug 2002 14:19:50 -0000	1.120
  @@ -176,6 +176,12 @@
           objectValue = value;
       }
   
  +    public MessageElement(QName name, Object value)
  +    {
  +        this(name.getNamespaceURI(), name.getLocalPart());
  +        objectValue = value;
  +    }
  +
       public MessageElement(Element elem)
       {
           elementRep = elem;
  @@ -752,7 +758,7 @@
           if (objectValue != null) {
               context.serialize(new QName(namespaceURI, name),
                                 attributes,
  -                              objectValue);
  +                              objectValue, null, false, Boolean.TRUE);
               return;
           }
   
  
  
  
  1.25      +4 -5      xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java
  
  Index: SymbolTable.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- SymbolTable.java	15 Aug 2002 21:27:47 -0000	1.24
  +++ SymbolTable.java	18 Aug 2002 14:19:50 -0000	1.25
  @@ -708,11 +708,10 @@
                   }
               }
               else if (isXSD && localPart.equals("any")) {
  -                // Map xsd:any element to any xsd:any so that
  -                // it gets serialized using the ElementSerializer.
  -                QName anyQName = Constants.XSD_ANY;
  -                if (getType(anyQName) == null) {
  -                    symbolTablePut(new BaseType(anyQName));
  +                // Map xsd:any element to special xsd:any "type"
  +                if (getType(Constants.XSD_ANY) == null) {
  +                    Type type = new BaseType(Constants.XSD_ANY);
  +                    symbolTablePut(type);
                   }
               }
               else if (localPart.equals("part") &&
  
  
  
  1.23      +1 -1      xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java
  
  Index: JavaBeanWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JavaBeanWriter.java	16 Aug 2002 11:07:10 -0000	1.22
  +++ JavaBeanWriter.java	18 Aug 2002 14:19:50 -0000	1.23
  @@ -194,7 +194,7 @@
                   String typeName = elem.getType().getName();
                   String variableName;
                   if (elem.getAnyElement()) {
  -                    typeName = "java.lang.Object";
  +                    typeName = "org.apache.axis.message.MessageElement []";
                       variableName = Constants.ANYCONTENT;
                   } else {
                       String elemName = elem.getName().getLocalPart();
  
  
  
  1.15      +4 -2      xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryBindingImpl.java
  
  Index: ExtensibilityQueryBindingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryBindingImpl.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ExtensibilityQueryBindingImpl.java	16 Aug 2002 11:07:10 -0000	1.14
  +++ ExtensibilityQueryBindingImpl.java	18 Aug 2002 14:19:50 -0000	1.15
  @@ -13,6 +13,7 @@
   import org.apache.axis.message.SOAPBodyElement;
   import org.apache.axis.message.RPCParam;
   import org.apache.axis.message.RPCElement;
  +import org.apache.axis.message.MessageElement;
   import org.apache.axis.encoding.SerializationContextImpl;
   import org.apache.axis.encoding.SerializationContext;
   import org.apache.axis.encoding.DeserializationContext;
  @@ -45,7 +46,7 @@
   
       public ExtensibilityType query(ExtensibilityType query) throws RemoteException {
           ExtensibilityType result = new ExtensibilityType();
  -        Object obj = query.getAny();
  +        Object obj = query.get_any()[0].getObjectValue();
           if (obj instanceof FindBooksQueryExpressionElement) {
               BookType bookQuery = ((FindBooksQueryExpressionElement)obj).getBookQuery();
               String subject = bookQuery.getSubject();
  @@ -64,7 +65,8 @@
                   queryResult[i].setQueryType(new QName("urn:QueryType","BookQuery"));
               }
               resultList.setResult(queryResult);
  -            result.setAny(resultElement);
  +            MessageElement me = new MessageElement("foo", "bar", resultElement);
  +            result.set_any(new MessageElement [] { me });
           } else {
               throw new RemoteException("Failed to get FindBooksQueryExpressionElement. Got:
" + obj.getClass().getName() + ":" + obj.toString());
           }
  
  
  
  1.12      +6 -2      xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryTestCase.java
  
  Index: ExtensibilityQueryTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryTestCase.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ExtensibilityQueryTestCase.java	16 Aug 2002 11:07:10 -0000	1.11
  +++ ExtensibilityQueryTestCase.java	18 Aug 2002 14:19:50 -0000	1.12
  @@ -9,6 +9,7 @@
   
   import org.apache.axis.EngineConfiguration;
   import org.apache.axis.AxisEngine;
  +import org.apache.axis.message.MessageElement;
   import org.apache.axis.client.AdminClient;
   import org.apache.axis.encoding.TypeMappingRegistry;
   import org.apache.axis.encoding.ser.BeanSerializerFactory;
  @@ -53,9 +54,12 @@
               BookType book = new BookType();
               book.setSubject("all");
               bookQuery.setBookQuery(book);
  -            expression.setAny(bookQuery); 
  +            MessageElement el = new MessageElement("foo", "Bar", bookQuery);
  +            expression.set_any(new MessageElement [] { el });
               ExtensibilityType any = binding.query(expression);
  -            QueryResultElement resEl = (QueryResultElement ) any.getAny();
  +            MessageElement [] anyContent = any.get_any();
  +            assertEquals(1, anyContent.length);
  +            QueryResultElement resEl = (QueryResultElement )anyContent[0].getObjectValue();
               ResultListType result = resEl.getResultList();
               QueryResultType[] queryResult = result.getResult();
               assertTrue(queryResult.length == 2); 
  
  
  
  1.6       +6 -1      xml-axis/java/test/wsdl/nested/Nested2BindingImpl.java
  
  Index: Nested2BindingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/nested/Nested2BindingImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Nested2BindingImpl.java	16 Aug 2002 16:06:02 -0000	1.5
  +++ Nested2BindingImpl.java	18 Aug 2002 14:19:50 -0000	1.6
  @@ -8,6 +8,9 @@
   package test.wsdl.nested;
   import test.wsdl.nested.holders.RETURNHolder;
   import test.wsdl.nested.holders.PE_ADDRESSHolder;
  +import org.apache.axis.message.MessageElement;
  +
  +import javax.xml.namespace.QName;
   
   public class Nested2BindingImpl implements test.wsdl.nested.Nested2PortType {
       public void nestedSvc2(java.lang.String cUSTOMERNO, java.lang.String pIDISTRCHAN, java.lang.String
pIDIVISION, java.lang.String pIPASSBUFFER, java.lang.String pISALESORG, PE_ADDRESSHolder pE_ADDRESS,
RETURNHolder rETURN) throws java.rmi.RemoteException {
  @@ -35,7 +38,9 @@
           address.setCURRENCY_ISO("");
           address.setCOUNTRYISO("DE");
           address.setONLY_CHANGE_COMADDRESS("X");
  -        address.setAny("Test Any");
  +        MessageElement me = new MessageElement(new QName("foo", "bar"),
  +                                               "Test Any");
  +        address.set_any(new MessageElement [] { me });
   
           RETURN ret = new RETURN();
           ret.setTYPE("");
  
  
  
  1.7       +5 -1      xml-axis/java/test/wsdl/nested/Nested2ServiceTestCase.java
  
  Index: Nested2ServiceTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/nested/Nested2ServiceTestCase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Nested2ServiceTestCase.java	16 Aug 2002 16:06:02 -0000	1.6
  +++ Nested2ServiceTestCase.java	18 Aug 2002 14:19:50 -0000	1.7
  @@ -8,6 +8,7 @@
   package test.wsdl.nested;
   import test.wsdl.nested.holders.PE_ADDRESSHolder;
   import test.wsdl.nested.holders.RETURNHolder;
  +import org.apache.axis.message.MessageElement;
   
   public class Nested2ServiceTestCase extends junit.framework.TestCase {
       public Nested2ServiceTestCase(String name) {
  @@ -37,7 +38,10 @@
               RETURN ret = rETURN.value;
               assertTrue("NAME is wrong", address.getNAME().equals("Becker Berlin"));
               assertTrue("LOGMSGNO is wrong", ret.getLOG_MSG_NO().equals("123456"));
  -            assertTrue("any is wrong:" + address.getAny(), address.getAny()!=null &&
address.getAny().equals("Test Any"));
  +            MessageElement [] any = address.get_any();
  +            assertNotNull("No 'any' content", any);
  +            assertTrue("any is wrong:" + any[0],
  +                       any[0].getObjectValue().equals("Test Any"));
           }
           catch (java.rmi.RemoteException re) {
               throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
  
  
  

Mime
View raw message