dims        2002/11/20 10:05:44

  Modified:    java/src/org/apache/axis/message EnvelopeBuilder.java
               java/src/org/apache/axis/i18n resource.properties
  Added:       java/test/soap12 PackageTests.java TestDeser.java
  Log:
  Fix for Bug 14710 - soap 1.2 doens't permit any element after body patch from 
[EMAIL PROTECTED] (Andras Avar)
  
  Notes:
  - I added a test case as well.
  
  Revision  Changes    Path
  1.30      +5 -2      xml-axis/java/src/org/apache/axis/message/EnvelopeBuilder.java
  
  Index: EnvelopeBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/EnvelopeBuilder.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- EnvelopeBuilder.java      15 Oct 2002 21:15:42 -0000      1.29
  +++ EnvelopeBuilder.java      20 Nov 2002 18:05:44 -0000      1.30
  @@ -55,9 +55,8 @@
   package org.apache.axis.message;
   
   import org.apache.axis.Constants;
  -import org.apache.axis.soap.SOAPConstants;
   import org.apache.axis.encoding.DeserializationContext;
  -import org.apache.axis.utils.JavaUtils;
  +import org.apache.axis.soap.SOAPConstants;
   import org.apache.axis.utils.Messages;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  @@ -157,6 +156,10 @@
           if (!gotBody)
               throw new SAXException(Messages.getMessage("noCustomElems00"));
   
  +        if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
  +            throw new SAXException(Messages.getMessage("noElemAfterBody12"));
  +        }
  +        
           MessageElement element = new MessageElement(namespace, localName, prefix,
                                        attributes, context);
   
  
  
  
  1.1                  xml-axis/java/test/soap12/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package test.soap12;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  /**
   */
  public class PackageTests 
  {
      public static void main (String[] args) {
              junit.textui.TestRunner.run (suite());
      }
  
      public static Test suite()
      {
          TestSuite suite = new TestSuite("All axis.soap12 tests");
  
          suite.addTestSuite(TestDeser.class);
          suite.addTestSuite(TestHeaderAttrs.class);
          //suite.addTestSuite(TestSer.class);
  
          return suite;
      }
  }
  
  
  
  1.1                  xml-axis/java/test/soap12/TestDeser.java
  
  Index: TestDeser.java
  ===================================================================
  package test.soap12;
  
  import junit.framework.TestCase;
  import org.apache.axis.Constants;
  import org.apache.axis.Message;
  import org.apache.axis.MessageContext;
  import org.apache.axis.utils.Messages;
  import org.apache.axis.message.RPCElement;
  import org.apache.axis.message.RPCParam;
  import org.apache.axis.message.SOAPEnvelope;
  import org.apache.axis.server.AxisServer;
  import org.apache.axis.soap.SOAPConstants;
  
  import java.util.Vector;
  /**
   * Test deserialization of SOAP responses
   */
  public class TestDeser extends TestCase {
  
      private AxisServer server = new AxisServer();
  
      public TestDeser(String name) {
          super(name);
      }
      
      String text1 = 
          "<?xml version=\"1.0\"?>\n" +
          "<soap:Envelope " +
            "xmlns:soap=\"http://www.w3.org/2002/06/soap-envelope\"; " +
            "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"; " +
            "xmlns:me=\"http://soapinterop.org/xsd\"; " +
            "xmlns:this=\"http://encoding.test\"; " + 
            "xmlns:xsi=\"" + Constants.URI_DEFAULT_SCHEMA_XSI + "\" " +
            "xmlns:xsd=\"" + Constants.URI_DEFAULT_SCHEMA_XSD + "\">\n" +
            "<soap:Body>\n" +
              "<methodResult xmlns=\"http://tempuri.org/\";>\n" +
              "<item xsi:type=\"xsd:string\">abc</item>\n" +
              "</methodResult>\n" +
            "</soap:Body>\n";
      String text2 =
          "</soap:Envelope>\n";
  
      public void testDeser1() throws Exception {
          assertEquals(deserialize(""), "abc");
      }
      
      public void testDeser2() throws Exception {
          boolean expectedExceptionThrown = false;
          try {
              deserialize("<hello/>");
          } catch (org.apache.axis.AxisFault af) {
              String expected = Messages.getMessage("noElemAfterBody12");
              if(af.getFaultString().indexOf(expected)!=-1)
                  expectedExceptionThrown = true;
          }
          assertTrue(expectedExceptionThrown);
      }
              
      public String deserialize (String extra) throws Exception {
          Message message = new Message(text1 + extra + text2);
          MessageContext context = new MessageContext(server);
          context.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
          
          message.setMessageContext(context);
  
          SOAPEnvelope envelope = message.getSOAPEnvelope();
          assertNotNull("SOAP envelope should not be null", envelope);
  
          RPCElement body = (RPCElement)envelope.getFirstBody();
          assertNotNull("SOAP body should not be null", body);
  
          Vector arglist = body.getParams();
          assertNotNull("arglist", arglist);
          assertTrue("param.size()<=0 {Should be > 0}", arglist.size()>0);
  
          RPCParam param = (RPCParam) arglist.get(0);
          assertNotNull("SOAP param should not be null", param);
  
          return (String)param.getValue();
      }
  }
  
  
  
  1.31      +1 -0      xml-axis/java/src/org/apache/axis/i18n/resource.properties
  
  Index: resource.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/i18n/resource.properties,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- resource.properties       19 Nov 2002 23:33:52 -0000      1.30
  +++ resource.properties       20 Nov 2002 18:05:44 -0000      1.31
  @@ -984,6 +984,7 @@
   wrongNamespace00=The XML Schema type ''{0}'' is not valid in the Schema version 
''{1}''.
   
   onlyOneBodyFor12=Only one body allowed for SOAP 1.2 RPC
  +noElemAfterBody12=No element allowed after SOAP 1.2 body
   differentTypes00=Error: The input and output parameter have the same name, ''{0}'', 
but are defined with type ''{1}'' and also with type ''{2}''.
   
   badMsgMethodParam=Message service must take either a single Vector or a Document - 
method {0} takes a single {1}
  
  
  


Reply via email to