axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: xml-axis/java/test/functional TestElementSample.java FunctionalTests.java
Date Wed, 12 Dec 2001 14:02:28 GMT
dug         01/12/12 06:02:28

  Modified:    java/src/org/apache/axis/encoding ElementSerializer.java
                        TypeMappingRegistry.java
               java/test/functional FunctionalTests.java
  Added:       java/samples/encoding ElementService.java
                        ElementService.wsdl deploy.wsdd testElement.java
                        undeploy.wsdd
               java/test/functional TestElementSample.java
  Log:
  Make the Element serializer work properly - it wasn't wrapping
  the Element with the parameter name, attributes...
  So some extra attributes were showing up in the Element itself.
  
  *** SAM: Can we this (just code w/o test is ok) put back into
           alpha-3
  
  Revision  Changes    Path
  1.1                  xml-axis/java/samples/encoding/ElementService.java
  
  Index: ElementService.java
  ===================================================================
  package samples.encoding;
  
  import org.w3c.dom.Element ;
  
  public class ElementService {
      public Element echoElement(String str, Element elem) {
          return( elem );
      }
  }
  
  
  
  1.1                  xml-axis/java/samples/encoding/ElementService.wsdl
  
  Index: ElementService.wsdl
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <wsdl:definitions 
          targetNamespace="http://localhost:8080/axis/services/ElementService"
          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          xmlns:intf="http://localhost:8080/axis/services/ElementService"
          xmlns:impl="http://localhost:8080/axis/services/ElementService-impl"
          xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
          xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
          xmlns:tns1="http://xml.apache.org/xml-soap"
          xmlns="http://schemas.xmlsoap.org/wsdl/">
          <types>
            <schema xmlns="http://www.w3.org/2001/XMLSchema"
                    targetNamespace="http://xml.apache.org/xml-soap">
               <complexType name="Element"><all/>
               </complexType>
               <element name="Element" nillable="true" type="tns1:Element"/>
            </schema>
          </types>
    <wsdl:message name="echoElementRequest">
      <wsdl:part name="in0" type="xsd:string"/>
      <wsdl:part name="in1" type="tns1:Element"/>
    </wsdl:message>
    <wsdl:message name="echoElementResponse">
      <wsdl:part name="echoElementResult" type="tns1:Element"/>
    </wsdl:message>
    <wsdl:portType name="ElementService">
      <wsdl:operation name="echoElement">
        <wsdl:input message="intf:echoElementRequest"/>
        <wsdl:output message="intf:echoElementResponse"/>
      </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="ElementServiceSoapBinding" type="intf:ElementService">
      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="echoElement">
        <soap:operation soapAction="" style="rpc"/>
        <wsdl:input>
          <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost:8080/axis/services/ElementService"/>
        </wsdl:input>
        <wsdl:output>
          <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost:8080/axis/services/ElementService"/>
        </wsdl:output>
      </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="ElementServiceService">
      <wsdl:port name="ElementService" binding="intf:ElementServiceSoapBinding">
        <soap:address location="http://localhost:8080/axis/services/ElementService"/>
      </wsdl:port>
    </wsdl:service>
  </wsdl:definitions>
  
  
  
  1.1                  xml-axis/java/samples/encoding/deploy.wsdd
  
  Index: deploy.wsdd
  ===================================================================
  <deployment name="test" xmlns="http://xml.apache.org/axis/wsdd/"
              xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
              xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
    <service name="ElementService" provider="java:RPC">
      <parameter name="className" value="samples.encoding.ElementService" />
      <parameter name="methodName" value="echoElement" />
    </service>
  </deployment>
  
  
  
  1.1                  xml-axis/java/samples/encoding/testElement.java
  
  Index: testElement.java
  ===================================================================
  package samples.encoding;
  
  import org.apache.axis.client.* ;
  import org.apache.axis.utils.* ;
  import java.io.*;
  import java.net.*;
  import javax.xml.rpc.namespace.*;
  import org.w3c.dom.Element ;
  
  public class testElement {
      static String xml = "<x:hello xmlns:x=\"urn:foo\">a string</x:hello>" ;
  
      public static String doit(String[] args,String xml) throws Exception {
          ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
  
          String  sURL = "http://localhost:8080/axis/services/ElementService" ;
          QName   sqn  = new QName(sURL, "ElementServiceService" );
          QName   pqn  = new QName(sURL, "ElementService" );
  
          //Service service=new Service(new URL("file:ElementService.wsdl"),sqn);
          Service service = new Service(new URL(sURL+"?wsdl"),sqn);
          Call    call    = (Call) service.createCall( pqn, "echoElement" );
  
          Options opts = new Options(args);
          opts.setDefaultURL( call.getTargetEndpointAddress() );
          call.setTargetEndpointAddress( new URL(opts.getURL()) );
  
          Element elem = XMLUtils.newDocument(bais).getDocumentElement();
  
          elem = (Element) call.invoke( new Object[] { "a string", elem } );
          return( XMLUtils.ElementToString( elem ) );
      }
  
      public static void main(String[] args) throws Exception {
          System.out.println("Sent: " + xml );
          String res = doit(args, xml);
          System.out.println("Returned: " + res );
      }
  }
  
  
  
  1.1                  xml-axis/java/samples/encoding/undeploy.wsdd
  
  Index: undeploy.wsdd
  ===================================================================
  <undeployment name="test" xmlns="http://xml.apache.org/axis/wsdd/">
    <service name="ElementService"/>
  </undeployment>
  
  
  
  1.4       +14 -2     xml-axis/java/src/org/apache/axis/encoding/ElementSerializer.java
  
  Index: ElementSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ElementSerializer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ElementSerializer.java	2001/12/11 18:40:33	1.3
  +++ ElementSerializer.java	2001/12/12 14:02:27	1.4
  @@ -66,6 +66,7 @@
   
   import javax.xml.rpc.namespace.QName;
   import java.io.IOException;
  +import java.util.ArrayList;
   
   /**
    * Serializer for DOM elements
  @@ -82,8 +83,10 @@
       {
           if (!(value instanceof Element))
               throw new IOException(JavaUtils.getMessage("cantSerialize01"));
  -        
  +
  +        context.startElement(name, attributes);
           context.writeDOMElement((Element)value);
  +        context.endElement();
       }
   
       // Our static deserializer factory
  @@ -99,9 +102,18 @@
                                  throws SAXException
       {
           try {
  -            value = context.getCurElement().getAsDOM();
  +            MessageElement msgElem = context.getCurElement();
  +            if ( msgElem != null ) {
  +                ArrayList children = msgElem.getChildren();
  +                if ( children != null ) {
  +                    msgElem = (MessageElement) children.get(0);
  +                    if ( msgElem != null )
  +                        value = msgElem.getAsDOM();
  +                }
  +            }
           }
           catch( Exception exp ) {
  +            exp.printStackTrace();
               throw new SAXException( exp );
           }
       }
  
  
  
  1.39      +1 -2      xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java
  
  Index: TypeMappingRegistry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- TypeMappingRegistry.java	2001/12/12 01:20:54	1.38
  +++ TypeMappingRegistry.java	2001/12/12 14:02:27	1.39
  @@ -229,8 +229,7 @@
           String prefix = context.
                              getPrefixForURI(Constants.URI_CURRENT_SCHEMA_XSI,
                                              "xsi");
  -        
  -        
  +
           attrs.addAttribute(Constants.URI_CURRENT_SCHEMA_XSI,
                              "type",
                              prefix + ":type",
  
  
  
  1.14      +3 -0      xml-axis/java/test/functional/FunctionalTests.java
  
  Index: FunctionalTests.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/functional/FunctionalTests.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- FunctionalTests.java	2001/10/31 23:50:22	1.13
  +++ FunctionalTests.java	2001/12/12 14:02:28	1.14
  @@ -43,6 +43,9 @@
           // Proxy service test.
           //suite.addTestSuite(TestProxySample.class);
   
  +        // Element service test.
  +        suite.addTestSuite(TestElementSample.class);
  +
           return suite;
       }
   }
  
  
  
  1.1                  xml-axis/java/test/functional/TestElementSample.java
  
  Index: TestElementSample.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 apache@apache.org.
   *
   * 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.functional;
  
  import junit.framework.TestCase;
  import org.apache.axis.AxisFault;
  import org.apache.axis.client.AdminClient;
  import org.apache.log4j.Category;
  import samples.encoding.testElement;
  
  /** Test the ElementService sample code.
   */
  public class TestElementSample extends TestCase {
      static Category category =
              Category.getInstance(TestElementSample.class.getName());
  
      public TestElementSample(String name) {
          super(name);
      }
      
      public void doTestElement () throws Exception {
          String[] args = {};
          String   xml = "<x:hello xmlns:x=\"urn:foo\">a string</x:hello>";
          System.out.println("Sending : " + xml );
          String res = new testElement().doit(args, xml);
          System.out.println("Received: " + res );
          assertEquals("TestElementSample.doit(): xml must match", res, xml);
      }
      
      public void doTestDeploy () throws Exception {
          String[] args = { "samples/encoding/deploy.wsdd" };
          AdminClient.main(args);
      }
      
      public void doTestUndeploy () throws Exception {
          String[] args = { "samples/encoding/undeploy.wsdd" };
          AdminClient.main(args);
      }
  
      public static void main(String args[]) throws Exception {
          TestElementSample tester = new TestElementSample("tester");
          tester.testElementService();
      }
  
      public void testElementService () throws Exception {
          try {
              category.info("Testing element sample.");
              category.info("Testing deployment...");
              doTestDeploy();
              category.info("Testing service...");
              doTestElement();
              category.info("Testing undeployment...");
              doTestUndeploy();
              category.info("Test complete.");
          }
          catch( Exception e ) {
              if ( e instanceof AxisFault ) ((AxisFault)e).dump();
              e.printStackTrace();
              throw new Exception("Fault returned from test: "+e);
          }
      }
      
  }
  
  
  
  
  

Mime
View raw message