axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/test/wsdl/extensibility ExtensibilityQuery.wsdl ExtensibilityQueryBindingImpl.java ExtensibilityQueryTestCase.java server-deploy.wsdd
Date Wed, 24 Mar 2004 19:44:59 GMT
dims        2004/03/24 11:44:59

  Modified:    java/src/org/apache/axis/encoding/ser BeanDeserializer.java
               java/test/wsdl/extensibility ExtensibilityQuery.wsdl
                        ExtensibilityQueryBindingImpl.java
                        ExtensibilityQueryTestCase.java server-deploy.wsdd
  Log:
  Fix for  AXIS-1263 - Mixed content patch to BeanDeserializer
  from jarek gawor
  
  Revision  Changes    Path
  1.65      +43 -0     ws-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java
  
  Index: BeanDeserializer.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- BeanDeserializer.java	25 Feb 2004 14:02:36 -0000	1.64
  +++ BeanDeserializer.java	24 Mar 2004 19:44:58 -0000	1.65
  @@ -35,6 +35,7 @@
   
   import javax.xml.namespace.QName;
   import java.io.Serializable;
  +import java.io.CharArrayWriter;
   import java.util.Map;
   
   /**
  @@ -49,6 +50,8 @@
       protected static Log log =
           LogFactory.getLog(BeanDeserializer.class.getName());
   
  +    private final CharArrayWriter val = new CharArrayWriter();
  +
       QName xmlType;
       Class javaType;
       protected Map propertyMap = null;
  @@ -147,6 +150,8 @@
                                       DeserializationContext context)
           throws SAXException
       {
  +        handleMixedContent();
  +
           BeanPropertyDescriptor propDesc = null;
           FieldDesc fieldDesc = null;
   
  @@ -446,5 +451,43 @@
               cacheXMLType = xmlType;
           }
           return dSer;
  +    }
  +
  +    public void characters(char[] chars, int start, int end) throws SAXException {
  +        val.write(chars, start, end);
  +    }
  +
  +    public void onEndElement(String namespace, String localName,
  +                             DeserializationContext context) throws SAXException {
  +        handleMixedContent();
  +    }
  +
  +    protected void handleMixedContent() throws SAXException {
  +        BeanPropertyDescriptor propDesc = getAnyPropertyDesc();
  +        if (propDesc == null || val.size() == 0) {
  +            return;
  +        }
  +        String textValue = val.toString().trim();
  +        val.reset();
  +        if (textValue.length() == 0) {
  +            return;
  +        }
  +        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 = new org.apache.axis.message.Text(textValue);
  +            newElements[length] = thisEl;
  +            propDesc.set(value, newElements);
  +        } catch (Exception e) {
  +            throw new SAXException(e);
  +        }
       }
   }
  
  
  
  1.3       +37 -0     ws-axis/java/test/wsdl/extensibility/ExtensibilityQuery.wsdl
  
  Index: ExtensibilityQuery.wsdl
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/wsdl/extensibility/ExtensibilityQuery.wsdl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExtensibilityQuery.wsdl	15 Dec 2003 20:58:01 -0000	1.2
  +++ ExtensibilityQuery.wsdl	24 Mar 2004 19:44:58 -0000	1.3
  @@ -29,6 +29,22 @@
           </xsd:complexType>
         </xsd:element>
   
  +      <xsd:element name="mixedQuery">
  +        <xsd:complexType>
  +          <xsd:sequence>
  +            <xsd:element name="queryExpression" type="tns:ExtensibilityType"/>
  +          </xsd:sequence>
  +        </xsd:complexType>
  +      </xsd:element>
  +
  +      <xsd:element name="mixedQueryResponse">
  +        <xsd:complexType>
  +          <xsd:sequence>
  +            <xsd:element name="queryResult" type="tns:ExtensibilityType"/>
  +          </xsd:sequence>
  +        </xsd:complexType>
  +      </xsd:element>
  +
       </xsd:schema>
     </types>
   
  @@ -40,11 +56,23 @@
       <part element="tns:queryResponse" name="parameters" />
     </message>
   
  +  <message name="mixedQueryIn">
  +    <part element="tns:mixedQuery" name="parameters" />
  +  </message>
  +
  +  <message name="mixedQueryOut">
  +    <part element="tns:mixedQueryResponse" name="parameters" />
  +  </message>
  +
     <portType name="ExtensibilityQueryPortType">
       <operation name="query">
         <input message="tns:queryIn" />
         <output message="tns:queryOut" />
       </operation>
  +   <operation name="mixedQuery">
  +      <input message="tns:mixedQueryIn" />
  +      <output message="tns:mixedQueryOut" />
  +    </operation>
     </portType>
   
     <binding name="ExtensibilityQueryBinding" type="tns:ExtensibilityQueryPortType">
  @@ -52,6 +80,15 @@
       transport="http://schemas.xmlsoap.org/soap/http" />
       <operation name="query">
         <soap:operation soapAction="query" />
  +      <input>
  +        <soap:body use="literal" />
  +      </input>
  +      <output>
  +        <soap:body use="literal" />
  +      </output>
  +    </operation>
  +    <operation name="mixedQuery">
  +      <soap:operation soapAction="mixedQuery" />
         <input>
           <soap:body use="literal" />
         </input>
  
  
  
  1.19      +55 -0     ws-axis/java/test/wsdl/extensibility/ExtensibilityQueryBindingImpl.java
  
  Index: ExtensibilityQueryBindingImpl.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/wsdl/extensibility/ExtensibilityQueryBindingImpl.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ExtensibilityQueryBindingImpl.java	18 Jun 2003 23:01:52 -0000	1.18
  +++ ExtensibilityQueryBindingImpl.java	24 Mar 2004 19:44:58 -0000	1.19
  @@ -14,6 +14,7 @@
   import org.apache.axis.encoding.SerializationContext;
   import org.apache.axis.encoding.SerializationContextImpl;
   import org.apache.axis.message.MessageElement;
  +import org.apache.axis.message.Text;
   import org.apache.axis.message.RPCElement;
   import org.apache.axis.message.RPCParam;
   import org.apache.axis.message.SOAPBodyElement;
  @@ -79,5 +80,59 @@
               throw new RemoteException("Failed to get FindBooksQueryExpressionElement. Got:
" + obj);
           }
           return result;
  +    }
  +    
  +    public ExtensibilityType mixedQuery(ExtensibilityType query) 
  +    throws RemoteException {
  +    MessageElement [] elements = query.get_any();
  +    if (elements == null) {
  +        throw new RemoteException("No any");
  +    }
  +    if (elements.length != 3) {
  +        throw new RemoteException("Expected: 3 got: " + elements.length +
  +                      " element");
  +    }
  +
  +    String expected = "123  456";
  +    String received = elements[0].toString();
  +
  +    if (!expected.equals(received)) {
  +        throw new RemoteException("Expected: " + expected + 
  +                      " received: " + received);
  +    }
  +
  +    Object obj = null;
  +        try {
  +            obj = elements[1].getObjectValue(BookType.class);
  +        } catch (Exception e) {
  +            throw new RemoteException("Failed to deserialize", e);
  +        }
  +    BookType bookQuery = (BookType)obj;
  +    String subject = bookQuery.getSubject();
  +    if (!"all".equals(subject)) {
  +        throw new RemoteException("ExtensibilityQueryBindingImpl: Book subject query should
be all, instead was " + subject);
  +    }
  +
  +    expected = "789";
  +    received = elements[2].toString();
  +    
  +    if (!expected.equals(received)) {
  +        throw new RemoteException("Expected: " + expected + 
  +                      " received: " + received);
  +    }
  +
  +    ExtensibilityType reply = new ExtensibilityType(); 
  +
  +    MessageElement [] replyElements = new MessageElement[2];
  +
  +    BookType book = new BookType();
  +    book.setSubject("gotAll");
  +    QName elementName = _FindBooksQueryExpressionElement.getTypeDesc().getFields()[0].getXmlName();
  +    replyElements[0] = new MessageElement(elementName.getNamespaceURI(), elementName.getLocalPart(),
book);
  +    replyElements[1] = new Text("ABCD");
  +    
  +    reply.set_any(replyElements);
  +
  +    return reply;
       }
   }
  
  
  
  1.21      +73 -0     ws-axis/java/test/wsdl/extensibility/ExtensibilityQueryTestCase.java
  
  Index: ExtensibilityQueryTestCase.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/wsdl/extensibility/ExtensibilityQueryTestCase.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ExtensibilityQueryTestCase.java	15 Dec 2003 20:58:01 -0000	1.20
  +++ ExtensibilityQueryTestCase.java	24 Mar 2004 19:44:58 -0000	1.21
  @@ -10,6 +10,7 @@
   import org.apache.axis.client.AdminClient;
   import org.apache.axis.components.logger.LogFactory;
   import org.apache.axis.message.MessageElement;
  +import org.apache.axis.message.Text;
   import org.apache.axis.utils.Options;
   import org.apache.commons.logging.Log;
   import org.apache.log4j.Logger;
  @@ -69,6 +70,78 @@
               assertTrue(queryResult.length == 2); 
               isValid(queryResult[0], "Computer Science", "The Grid"); 
               isValid(queryResult[1], "English", "The Oxford Dictionary"); 
  +        }
  +        catch (Exception e) {
  +            e.printStackTrace();
  +            throw new junit.framework.AssertionFailedError("Exception caught: " + e);
  +        }
  +    }
  +
  +    public void testMixedQuery() {
  +        ExtensibilityQueryPortType binding;
  +        try {
  +            ExtensibilityQueryLocator locator = new ExtensibilityQueryLocator();
  +            binding = locator.getExtensibilityQueryPort();
  +            deployServer();
  +        }
  +        catch (javax.xml.rpc.ServiceException jre) {
  +            throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught:
" + jre);
  +        } 
  +        catch (Exception e) {
  +            throw new junit.framework.AssertionFailedError("Binding initialization Exception
caught: " + e);
  +        }
  +        assertTrue("binding is null", binding != null);
  +
  +        try {
  +        ExtensibilityType expression = new ExtensibilityType(); 
  +
  +        MessageElement [] elements = new MessageElement[4];
  +
  +            elements[0] = new Text("123");
  +        elements[1] = new Text("  456");
  +        
  +            BookType book = new BookType();
  +            book.setSubject("all");
  +            QName elementName = _FindBooksQueryExpressionElement.getTypeDesc().getFields()[0].getXmlName();
  +            elements[2] = new MessageElement(elementName.getNamespaceURI(), elementName.getLocalPart(),
book);
  +
  +        elements[3] = new Text("789");
  +
  +            expression.set_any(elements);
  +
  +            // call the operation
  +            ExtensibilityType any = binding.mixedQuery(expression);
  +
  +        if (any == null) {
  +        throw new Exception("No output returned");
  +        }
  +
  +        // validate results
  +            MessageElement [] anyContent = any.get_any();
  +
  +        if (anyContent == null) {
  +        throw new Exception("No any");
  +        }
  +        if (anyContent.length != 2) {
  +        throw new Exception("Expected: 2 got: " + 
  +                    anyContent.length + " element");
  +        }
  +
  +        Object obj = anyContent[0].getObjectValue(BookType.class);
  +        BookType bookQuery = (BookType)obj;
  +        String subject = bookQuery.getSubject();
  +        if (!"gotAll".equals(subject)) {
  +        throw new Exception("Book subject query reply should be gotAll, instead was " +
subject);
  +        }
  +
  +        String expected = "ABCD";
  +        String received = anyContent[1].toString();
  +
  +        if (!expected.equals(received)) {
  +        throw new Exception("Expected: " + expected + 
  +                    " received: " + received);
  +        }
  +        
           }
           catch (Exception e) {
               e.printStackTrace();
  
  
  
  1.11      +1 -1      ws-axis/java/test/wsdl/extensibility/server-deploy.wsdd
  
  Index: server-deploy.wsdd
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/wsdl/extensibility/server-deploy.wsdd,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- server-deploy.wsdd	15 Dec 2003 20:58:01 -0000	1.10
  +++ server-deploy.wsdd	24 Mar 2004 19:44:58 -0000	1.11
  @@ -22,7 +22,7 @@
           <operation name="query" qname="operNS:query" xmlns:operNS="urn:ExtensibilityQuery"
returnQName="retNS:queryResult" xmlns:retNS="urn:ExtensibilityQuery" returnType="rtns:ExtensibilityType"
xmlns:rtns="urn:ExtensibilityQuery" >
             <parameter qname="pns:queryExpression" xmlns:pns="urn:ExtensibilityQuery"
type="tns:ExtensibilityType" xmlns:tns="urn:ExtensibilityQuery"/>
           </operation>
  -        <parameter name="allowedMethods" value="query"/>
  +        <parameter name="allowedMethods" value="*"/>
           <parameter name="scope" value="Session"/>
   
           <typeMapping
  
  
  

Mime
View raw message