axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bu...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/oneway OnewayImpl.java OnewayTestCase.java build.xml oneway.wsdl
Date Mon, 16 Sep 2002 15:55:56 GMT
butek       2002/09/16 08:55:56

  Modified:    java/samples/addr AddressBook.wsdl
               java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java
               java/test/wsdl/arrays ArrayTest.wsdl
  Added:       java/test/wsdl/oneway OnewayImpl.java OnewayTestCase.java
                        build.xml oneway.wsdl
  Log:
  Fixed http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12528.  For
  oneway operations, stubs now call _call.invokeOneWay.  I also wrote a
  oneway test.
  
  This fix exposed two tests that had oneway operations which should not
  have been oneway operations:  address book and arrays.
  
  Revision  Changes    Path
  1.9       +3 -0      xml-axis/java/samples/addr/AddressBook.wsdl
  
  Index: AddressBook.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/addr/AddressBook.wsdl,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AddressBook.wsdl	1 Nov 2001 16:52:12 -0000	1.8
  +++ AddressBook.wsdl	16 Sep 2002 15:55:56 -0000	1.9
  @@ -43,6 +43,8 @@
     </types>
   
     <!-- message declns -->
  +  <message name="empty"/>
  +
     <message name="AddEntryRequest">
       <part name="name" type="xsd:string"/>
       <part name="address" type="typens:address"/>
  @@ -60,6 +62,7 @@
     <portType name="AddressBook">
       <operation name="addEntry">
         <input message="tns:AddEntryRequest"/>
  +      <output message="tns:empty"/>
       </operation>
       <operation name="getAddressFromName">
         <input message="tns:GetAddressFromNameRequest"/>
  
  
  
  1.93      +26 -9     xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
  
  Index: JavaStubWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- JavaStubWriter.java	9 Sep 2002 19:08:42 -0000	1.92
  +++ JavaStubWriter.java	16 Sep 2002 15:55:56 -0000	1.93
  @@ -270,7 +270,8 @@
                   pw.println();
               }
               else {
  -                writeOperation(pw, operation, parameters, soapAction, opStyle);
  +                writeOperation(pw, operation, parameters, soapAction, opStyle,
  +                        type == OperationType.ONE_WAY);
               }
           }
       } // writeFileBody
  @@ -471,7 +472,8 @@
               BindingOperation operation,
               Parameters parms,
               String soapAction,
  -            String opStyle) throws IOException {
  +            String opStyle,
  +            boolean oneway) throws IOException {
   
           writeComment(pw, operation.getDocumentationElement());
   
  @@ -614,12 +616,28 @@
                           Utils.getNewQName(elementQName) + ");" );
               }
           }
  +        pw.println();
   
           // Invoke the operation
  -        pw.println();
  -        pw.print("        java.lang.Object _resp = _call.invoke(");
  +        if (oneway) {
  +            pw.print("        _call.invokeOneWay(");
  +        }
  +        else {
  +            pw.print("        java.lang.Object _resp = _call.invoke(");
  +        }
           pw.print("new java.lang.Object[] {");
  +        writeParameters(pw, parms);
  +        pw.println("});");
  +        pw.println();
  +
  +        if (!oneway) {
  +            writeResponseHandling(pw, parms);
  +        }
  +        pw.println("    }");
  +        pw.println();
  +    } // writeOperation
   
  +    private void writeParameters(PrintWriter pw, Parameters parms) {
           // Write the input and inout parameter list
           boolean needComma = false;
           for (int i = 0; i < parms.list.size(); ++i) {
  @@ -644,8 +662,9 @@
                   pw.print(javifiedName);
               }
           }
  -        pw.println("});");
  -        pw.println();
  +    } // writeParamters
  +
  +    private void writeResponseHandling(PrintWriter pw, Parameters parms) {
           pw.println("        if (_resp instanceof java.rmi.RemoteException) {");
           pw.println("            throw (java.rmi.RemoteException)_resp;");
           pw.println("        }");
  @@ -698,9 +717,7 @@
               }
               pw.println("        }");
           }
  -        pw.println("    }");
  -        pw.println();
  -    } // writeOperation
  +    } // writeResponseHandling
   
       /** 
        * writeOutputAssign
  
  
  
  1.4       +3 -0      xml-axis/java/test/wsdl/arrays/ArrayTest.wsdl
  
  Index: ArrayTest.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/arrays/ArrayTest.wsdl,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ArrayTest.wsdl	31 May 2002 19:08:12 -0000	1.3
  +++ ArrayTest.wsdl	16 Sep 2002 15:55:56 -0000	1.4
  @@ -107,10 +107,13 @@
       <part name="id" type="xsd:int"/>
     </message>
   
  +  <message name="empty"/>
  +
     <!-- port type declns -->
     <portType name="PersonalInfoBook">
       <operation name="addEntry">
         <input message="tns:AddEntryRequest"/>
  +      <output message="tns:empty"/>
       </operation>
       <operation name="getPersonalInfoFromName">
         <input message="tns:GetPersonalInfoFromNameRequest"/>
  
  
  
  1.1                  xml-axis/java/test/wsdl/oneway/OnewayImpl.java
  
  Index: OnewayImpl.java
  ===================================================================
  /**
   * AddressBookSOAPBindingImpl.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis WSDL2Java emitter.
   */
  
  package test.wsdl.oneway;
  
  import java.rmi.RemoteException;
  
  import java.util.Hashtable;
  
  public class OnewayImpl implements Oneway {
      private Hashtable ht = new Hashtable();
  
      public void addEntry(String name, Address address) throws RemoteException {
          ht.put(name, address);
      }
  
      public Address getAddressFromName(String name) throws RemoteException {
          return (Address) ht.get(name);
      }
  
      public void throwException() throws RemoteException {
          throw new RemoteException("OnewayImpl throws RemoteException");
      }
  
  }
  
  
  
  1.1                  xml-axis/java/test/wsdl/oneway/OnewayTestCase.java
  
  Index: OnewayTestCase.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.wsdl.oneway;
  
  import junit.framework.AssertionFailedError;
  import junit.framework.TestCase;
  
  import java.rmi.RemoteException;
  
  import javax.xml.rpc.ServiceException;
  import javax.xml.rpc.Stub;
  
  /**
  * This tests various oneway operation features.
  */
  
  public class OnewayTestCase extends TestCase {
      public OnewayTestCase(String name) {
          super(name);
      }
  
      /**
       * Sessions shouldn't work with oneway operations, so the call to getAddressFromName
       * should return null.
       */
      public void test1NoSessionOnOneway() {
          Oneway binding;
          try {
              binding = new OnewayServiceLocator().getOneway();
          }
          catch (ServiceException jre) {
              throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
          }
          assertTrue("binding is null", binding != null);
  
          try {
              ((Stub) binding)._setProperty(Stub.SESSION_MAINTAIN_PROPERTY, new Boolean(true));
              binding.addEntry("hi", new Address());
              Address address = binding.getAddressFromName("hi");
              assertTrue("session doesn't work on oneway operations, address should have been
null", address == null);
          }
          catch (RemoteException re) {
              throw new AssertionFailedError("Remote Exception caught: " + re);
          }
      }
  
      /**
       * binding.throwException will cause the server impl to throw an exception,
       * but since this is a oneway operation, that exception should not propagate
       * back to the client.
       */
      public void test2NoExceptionOnOneway() {
          Oneway binding;
          try {
              binding = new OnewayServiceLocator().getOneway();
          }
          catch (ServiceException jre) {
              throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
          }
          assertTrue("binding is null", binding != null);
  
          try {
              binding.throwException();
          }
          catch (Throwable t) {
              throw new AssertionFailedError("Throwable: " + t);
          }
      }
  
  }
  
  
  
  1.1                  xml-axis/java/test/wsdl/oneway/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0" ?>
  <!DOCTYPE project [
          <!ENTITY properties SYSTEM "file:../../../xmls/properties.xml">
          <!ENTITY paths  SYSTEM "file:../../../xmls/path_refs.xml">
          <!ENTITY taskdefs SYSTEM "file:../../../xmls/taskdefs.xml">
          <!ENTITY taskdefs_post_compile SYSTEM "file:../../../xmls/taskdefs_post_compile.xml">
          <!ENTITY targets SYSTEM "file:../../../xmls/targets.xml">
  ]>
  
  <!-- ===================================================================
  <description>
     Test/Sample Component file for Axis
  
  Notes:
     This is a build file for use with the Jakarta Ant build tool.
  
  Prerequisites:
  
     jakarta-ant from http://jakarta.apache.org
  
  Build Instructions:
     To compile
          ant compile
     To execute
          ant run
  
  Author:
    Matt Seibert mseibert@us.ibm.com
  
  Copyright:
    Copyright (c) 2002-2003 Apache Software Foundation.
  </description>
  ==================================================================== -->
  
  <project default="compile">
  
  <property name="axis.home" location="../../.." />
  <property name="componentName" value="test/wsdl/oneway" />
          &properties;
          &paths;
          &taskdefs;
          &taskdefs_post_compile;
          &targets;
  
  <target name="clean">
      <echo message="Removing ${build.dir}/classes/${componentName} and ${build.dir}/work/${componentName}"
/>
      <delete dir="${build.dir}/classes/${componentName}"/>
      <delete dir="${build.dir}/work/${componentName}"/>
  </target>
  
  <target name="copy" depends="setenv"/>
  
  <target name="compile" depends="copy">
    <echo message="Compilibg test.wsdl.oneway"/>
      <!-- Oneway Test -->
      <!-- Generate Java From WSDL -->
      <wsdl2java url="${axis.home}/test/wsdl/oneway/oneway.wsdl"
                 output="${axis.home}/build/work"
                 serverSide="yes">
      </wsdl2java>
  
      <copy todir="${build.dir}/work/test/wsdl/oneway" overwrite="yes">
        <fileset dir="${axis.home}/test/wsdl/oneway">
          <include name="*TestCase.java"/>
          <include name="*Impl.java"/>
          <include name="deploy.wsdd"/>
        </fileset>
      </copy>
  
      <!-- Compile Java -->
      <javac srcdir="${build.dir}/work" destdir="${build.dest}" debug="${debug}" fork="${javac.fork}">
        <classpath refid="classpath" />
        <include name="test/wsdl/oneway/**.java" />
      </javac>
  </target>
  
  <target name="run" >
    <antcall target="execute-Component" />
  </target>
  
  </project>
  
  
  
  1.1                  xml-axis/java/test/wsdl/oneway/oneway.wsdl
  
  Index: oneway.wsdl
  ===================================================================
  <?xml version="1.0" ?>
  
  <definitions name="urn:oneway.wsdl.test"
               targetNamespace="urn:oneway.wsdl.test"
               xmlns:tns="urn:oneway.wsdl.test"
               xmlns:typens="urn:oneway.wsdl.test"
               xmlns:xsd="http://www.w3.org/1999/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
               xmlns="http://schemas.xmlsoap.org/wsdl/">
  
    <!-- type defs -->
    <types>
      <xsd:schema targetNamespace="urn:oneway.wsdl.test"
                  xmlns:xsd="http://www.w3.org/1999/XMLSchema">
  
        <xsd:simpleType name="stateType">
          <xsd:restriction base="xsd:string">
              <xsd:enumeration value="TX"/>                      
              <xsd:enumeration value="IN"/>                    
              <xsd:enumeration value="OH"/>                    
          </xsd:restriction>
        </xsd:simpleType>
  
        <xsd:complexType name="phone">
          <xsd:all>
              <xsd:element name="areaCode" type="xsd:int"/>
              <xsd:element name="exchange" type="xsd:string"/>
              <xsd:element name="number" type="xsd:string"/>
          </xsd:all>
        </xsd:complexType>
  
        <xsd:complexType name="address">
          <xsd:all>
              <xsd:element name="streetNum" type="xsd:int"/>
              <xsd:element name="streetName" type="xsd:string"/>
              <xsd:element name="city" type="xsd:string"/>
              <xsd:element name="state" type="typens:stateType"/>
              <xsd:element name="zip" type="xsd:int"/>
              <xsd:element name="phoneNumber" type="typens:phone"/>
          </xsd:all>
        </xsd:complexType>
      </xsd:schema>
    </types>
  
    <!-- message declns -->
    <message name="AddEntryRequest">
      <part name="name" type="xsd:string"/>
      <part name="address" type="typens:address"/>
    </message>
  
    <message name="GetAddressFromNameRequest">
      <part name="name" type="xsd:string"/>
    </message>
  
    <message name="GetAddressFromNameResponse">
      <part name="address" type="typens:address"/>
    </message>
  
    <message name="ThrowExceptionRequest"/>
  
    <!-- port type declns -->
    <portType name="Oneway">
      <operation name="addEntry">
        <input message="tns:AddEntryRequest"/>
      </operation>
      <operation name="getAddressFromName">
        <input message="tns:GetAddressFromNameRequest"/>
        <output message="tns:GetAddressFromNameResponse"/>
      </operation>
      <operation name="throwException">
        <input message="tns:ThrowExceptionRequest"/>
      </operation>
    </portType>
  
    <!-- binding declns -->
    <binding name="OnewayBinding" type="tns:Oneway">
      <soap:binding style="rpc"
                    transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="addEntry">
        <soap:operation soapAction=""/>
        <input>
          <soap:body use="encoded"
                     namespace="urn:oneway.wsdl.test"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output>
          <soap:body use="encoded"
                     namespace="urn:oneway.wsdl.test"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
      </operation>
      <operation name="getAddressFromName">
        <soap:operation soapAction=""/>
        <input>
          <soap:body use="encoded"
                     namespace="urn:oneway.wsdl.test"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output>
          <soap:body use="encoded"
                     namespace="urn:oneway.wsdl.test"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
      </operation>
      <operation name="throwException">
        <soap:operation soapAction=""/>
        <input>
          <soap:body use="encoded"
                     namespace="urn:oneway.wsdl.test"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
      </operation>
    </binding>
  
    <!-- service decln -->
    <service name="OnewayService">
      <port name="Oneway" binding="tns:OnewayBinding">
        <soap:address location="http://localhost:8080/axis/services/Oneway"/>
      </port>
    </service>
  
  </definitions>
  
  
  
  

Mime
View raw message