axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/addrNoImplSEI AddressBookNoImplSEISoapBindingImpl.java AddressBook.wsdl Main.java AddressBookSOAPBindingImpl.java
Date Fri, 14 Jun 2002 22:39:50 GMT
scheu       2002/06/14 15:39:50

  Modified:    java/src/org/apache/axis/description ServiceDesc.java
               java/src/org/apache/axis/encoding/ser BeanDeserializer.java
               java/test/wsdl Java2WsdlAntTask.java Wsdl2javaTestSuite.xml
               java/test/wsdl/addrNoImplSEI AddressBook.wsdl Main.java
  Added:       java/test/wsdl/addrNoImplSEI
                        AddressBookNoImplSEISoapBindingImpl.java
  Removed:     java/test/wsdl/addrNoImplSEI AddressBookSOAPBindingImpl.java
  Log:
  Problem:
     The class passed to Java2WSDL may contain methods that
     throw exceptions that are not allowed in an SEI.
  
     The operations in the SEI must throw RemoteException
     plus application specific exceptions.  General exceptions
     (like java.lang.Exception or java.lang.NullPointerException)
     are not allowed in the SEI.
  
  Solution:
     Changed the ServiceDesc code that creates the FaultDesc objects.
     A FaultDesc is not created for exceptions in the 'java' or 'javax'
     packages.  (Simple Change)
  
     I recently added an addrNoImplSEI testcase which tests proper
     processing if the server-side impl does not implement the SEI.
     (This test is meant to somewhat simulate a server-side EJB).
  
     I enhanced this testcase to roundtrip Java2WSDL and WSDL2Java.
     I added some general purpose throw clauses to the Impl class to
     make sure tht Java2WSDL properly ignored the exceptions when
     generating the SEI.
  
  Revision  Changes    Path
  1.27      +11 -6     xml-axis/java/src/org/apache/axis/description/ServiceDesc.java
  
  Index: ServiceDesc.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/ServiceDesc.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- ServiceDesc.java	11 Jun 2002 14:53:54 -0000	1.26
  +++ ServiceDesc.java	14 Jun 2002 22:39:50 -0000	1.27
  @@ -740,7 +740,12 @@
   
           for (int i=0; i < exceptionTypes.length; i++) {
               // Every remote method declares a java.rmi.RemoteException
  -            if (exceptionTypes[i] != java.rmi.RemoteException.class) {
  +            // Only interested in application specific exceptions.
  +            // Ignore java and javax package exceptions.
  +            Class ex = exceptionTypes[i];
  +            if (ex != java.rmi.RemoteException.class &&
  +                !ex.getName().startsWith("java.") &&
  +                !ex.getName().startsWith("javax.")) {
                   
                   // For JSR 101 v.1.0, there is a simple fault mapping
                   // and a complexType fault mapping...both mappings
  @@ -756,7 +761,7 @@
                   
   
                   /* Old Simple Type Mode                  
  -                Field[] f = exceptionTypes[i].getDeclaredFields();
  +                Field[] f = ex.getDeclaredFields();
                   ArrayList exceptionParams = new ArrayList();
                   for (int j = 0; j < f.length; j++) {
                       int mod = f[j].getModifiers();
  @@ -771,7 +776,7 @@
                           exceptionParams.add(param);
                       }
                   }
  -                String pkgAndClsName = exceptionTypes[i].getName();
  +                String pkgAndClsName = ex.getName();
                   FaultDesc fault = new FaultDesc();
                   fault.setName(pkgAndClsName);
                   fault.setParameters(exceptionParams);                
  @@ -783,12 +788,12 @@
                   ParameterDesc param = new ParameterDesc(
                        new QName("", "fault"),
                        ParameterDesc.IN,
  -                     tm.getTypeQName(exceptionTypes[i]));
  -                param.setJavaType(exceptionTypes[i]);
  +                     tm.getTypeQName(ex));
  +                param.setJavaType(ex);
                   ArrayList exceptionParams = new ArrayList();
                   exceptionParams.add(param);
   
  -                String pkgAndClsName = exceptionTypes[i].getName();
  +                String pkgAndClsName = ex.getName();
                   FaultDesc fault = new FaultDesc();
                   fault.setName(pkgAndClsName);
                   fault.setParameters(exceptionParams);                
  
  
  
  1.32      +3 -3      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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- BeanDeserializer.java	11 Jun 2002 14:53:55 -0000	1.31
  +++ BeanDeserializer.java	14 Jun 2002 22:39:50 -0000	1.32
  @@ -301,15 +301,15 @@
                   // Success!  Register the target and deserializer.
                   collectionIndex = -1;
                   dSer.registerValueTarget(
  -                    new BeanPropertyTarget(value, propDesc));
  +                                         new BeanPropertyTarget(value, propDesc));
               } else {
                   // Success! This is a collection of properties so use the index
                   collectionIndex++;
                   dSer.registerValueTarget(
  -                     new BeanPropertyTarget(value, 
  +                                         new BeanPropertyTarget(value, 
                                               propDesc, 
                                               collectionIndex));
  -        }
  +            }
           }
           return (SOAPHandler)dSer;
       }
  
  
  
  1.13      +8 -0      xml-axis/java/test/wsdl/Java2WsdlAntTask.java
  
  Index: Java2WsdlAntTask.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/Java2WsdlAntTask.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Java2WsdlAntTask.java	31 May 2002 20:29:51 -0000	1.12
  +++ Java2WsdlAntTask.java	14 Jun 2002 22:39:50 -0000	1.13
  @@ -78,6 +78,7 @@
       private String output = "." ;
       private String className = "." ;
       private String servicePortName = null ;
  +    private String portTypeName = null ;
       private String implClass = null;
       private boolean useInheritedMethods = false;
       private String exclude = null;
  @@ -109,6 +110,8 @@
               }
               if (servicePortName != null)
                   emitter.setServicePortName(servicePortName);
  +            if (portTypeName != null)
  +                emitter.setPortTypeName(portTypeName);
               log("Java2WSDL " + className, Project.MSG_INFO);
               emitter.setCls(className);
               if (implClass != null)
  @@ -165,6 +168,11 @@
       // The setter for the "servicePortName" attribute
       public void setServicePortName(String parameter) {
           this.servicePortName = parameter;
  +    }
  +
  +    // The setter for the "portTypeName" attribute
  +    public void setPortTypeName(String parameter) {
  +        this.portTypeName = parameter;
       }
   
       // The setter for the "namespace" attribute
  
  
  
  1.104     +57 -1     xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml
  
  Index: Wsdl2javaTestSuite.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml,v
  retrieving revision 1.103
  retrieving revision 1.104
  diff -u -r1.103 -r1.104
  --- Wsdl2javaTestSuite.xml	12 Jun 2002 18:41:12 -0000	1.103
  +++ Wsdl2javaTestSuite.xml	14 Jun 2002 22:39:50 -0000	1.104
  @@ -73,7 +73,19 @@
           <mapping namespace="urn:MultiRefTest2" package="test.wsdl.multiref"/>
       </wsdl2java>
   
  -    <!-- AddressBook Sample -->
  +    <!-- AddressBook roundtrip example that does not implement SEI -->
  +    <!-- Summary -->
  +    <!-- Bootstrap the process by creating java classes from the original wsdl -->
  +    <!-- Compile the classes plus the provided Impl class -->
  +    <!--   The Impl class is supposed to simulate a server-side EJB -->
  +    <!--   It does not implement the SEI and it contains some additional throw clauses
-->
  +    <!-- Run Java2WSDL on the Impl class to ensure a valid wsdl is generated -->
  +    <!-- Run WSDL2Java on the new wsdl to ensure valid java artifacts are generated
-->
  +    <!--   This will ensure that java classes are not generated for NullPointerException
-->
  +    <!-- Copy back over the original Impl and test classes.  -->
  +    <!--   They will be compiled and run as part of the test. -->
  +    <delete dir="${build.dir}/classes/test/wsdl/addrNoImplSEI"/>
  +    <delete dir="${build.dir}/work/test/wsdl/addrNoImplSEI"/>
       <wsdl2java url="test/wsdl/addrNoImplSEI/AddressBook.wsdl"
                  output="build/work"
                  deployscope="session"
  @@ -85,6 +97,50 @@
                  testcase="no">
           <mapping namespace="urn:AddrNoImplSEI" package="test.wsdl.addrNoImplSEI"/>
       </wsdl2java>
  +
  +    <!-- Copy over original classes -->
  +    <copy todir="${build.dir}/work/test/wsdl/addrNoImplSEI" overwrite="yes">
  +      <fileset dir="${test.dir}/wsdl/addrNoImplSEI">
  +        <include name="*.java"/>
  +      </fileset>
  +    </copy>
  +
  +    <!-- Compile the Web Service -->
  +    <javac srcdir="${build.dir}/work" destdir="${build.dest}" debug="${debug}">
  +      <classpath refid="test-classpath" />
  +      <include name="test/wsdl/addrNoImplSEI/**.java" />
  +      <exclude name="test/wsdl/addrNoImplSEI/*TestCase.java" />
  +      <exclude name="test/wsdl/addrNoImplSEI/Main.java" />
  +    </javac>
  +
  +    <!-- Now run java to wsdl to make sure we don't have any strange artifacts -->
  +    <java2wsdl output="build/work/test/wsdl/addrNoImplSEI/AddressBook.wsdl"
  +               className= "test.wsdl.addrNoImplSEI.AddressBookNoImplSEISoapBindingImpl"
  +               useInheritedMethods="false"
  +               portTypeName="AddressBookNoImplSEI"
  +               namespace="http://addrNoImplSEI.wsdl.test"
  +               location="http://localhost:8080/axis/services/AddressBookNoImplSEI">
  +        <mapping namespace="urn:AddrNoImplSEI" package="test.wsdl.addrNoImplSEI"/>
  +    </java2wsdl> 
  +
  +    <!-- Now run wsdl to java to make sure we don't have any strange artifacts -->
  +    <wsdl2java url="build/work/test/wsdl/addrNoImplSEI/AddressBook.wsdl"
  +               output="build/work"
  +               deployscope="session"
  +               serverSide="yes"
  +               skeletonDeploy="no"
  +               noimports="no"
  +               verbose="no"
  +               typeMappingVersion="1.1"
  +               testcase="no">
  +        <mapping namespace="urn:AddrNoImplSEI" package="test.wsdl.addrNoImplSEI"/>
  +    </wsdl2java>
  +    <!-- Copy over original classes -->
  +    <copy todir="${build.dir}/work/test/wsdl/addrNoImplSEI" overwrite="yes">
  +      <fileset dir="${test.dir}/wsdl/addrNoImplSEI">
  +        <include name="*.java"/>
  +      </fileset>
  +    </copy>
   
       <!-- Operation style test (oneway, request/response, -->
       <!-- solicit/response, notification -->
  
  
  
  1.2       +4 -4      xml-axis/java/test/wsdl/addrNoImplSEI/AddressBook.wsdl
  
  Index: AddressBook.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/addrNoImplSEI/AddressBook.wsdl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AddressBook.wsdl	21 May 2002 17:15:50 -0000	1.1
  +++ AddressBook.wsdl	14 Jun 2002 22:39:50 -0000	1.2
  @@ -57,7 +57,7 @@
     </message>
   
     <!-- port type declns -->
  -  <portType name="AddressBook">
  +  <portType name="AddressBookNoImplSEI">
       <operation name="addEntry">
         <input message="tns:AddEntryRequest"/>
       </operation>
  @@ -68,7 +68,7 @@
     </portType>
   
     <!-- binding declns -->
  -  <binding name="AddressBookSOAPBinding" type="tns:AddressBook">
  +  <binding name="AddressBookNoImplSEISoapBinding" type="tns:AddressBookNoImplSEI">
       <soap:binding style="rpc"
                     transport="http://schemas.xmlsoap.org/soap/http"/>
       <operation name="addEntry">
  @@ -100,8 +100,8 @@
     </binding>
   
     <!-- service decln -->
  -  <service name="AddressBookService">
  -    <port name="AddressBookNoImplSEI" binding="tns:AddressBookSOAPBinding">
  +  <service name="AddressBookNoImplSEIService">
  +    <port name="AddressBookNoImplSEI" binding="tns:AddressBookNoImplSEISoapBinding">
         <soap:address location="http://localhost:8080/axis/services/AddressBookNoImplSEI"/>
       </port>
     </service>
  
  
  
  1.2       +18 -5     xml-axis/java/test/wsdl/addrNoImplSEI/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/addrNoImplSEI/Main.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Main.java	21 May 2002 17:15:50 -0000	1.1
  +++ Main.java	14 Jun 2002 22:39:50 -0000	1.2
  @@ -106,7 +106,7 @@
                                   ph.getExchange() + "-" + ph.getNumber());
       }
       
  -    private static Object doit (AddressBook ab) throws Exception {
  +    private static Object doit (AddressBookNoImplSEI ab) throws Exception {
           System.err.println (">> Storing address for '" + name1 + "'");
           ab.addEntry (name1, addr1);
           System.err.println (">> Querying address for '" + name1 + "'");
  @@ -121,6 +121,19 @@
           resp = ab.getAddressFromName (name1);
           System.err.println (">> Response is:");
           printAddress (resp);
  +        
  +        // Test NPE
  +        try {
  +            ab.addEntry(null, null);
  +            throw new Exception("Expected exception when calling addEntry with null params");
  +        } catch (java.rmi.RemoteException e) {
  +            if (e.detail instanceof java.lang.IllegalArgumentException) {
  +                // Good! Expected this!
  +            } else {
  +                throw e;  // This is not right!
  +            }            
  +        }
  +        
           return resp;
       }
       
  @@ -131,11 +144,11 @@
               System.err.println ("Using proxy without session maintenance.");
               System.err.println ("(queries without session should say:  \"ADDRESS NOT FOUND!\")");
   
  -            AddressBookService abs = new AddressBookServiceLocator();
  +            AddressBookNoImplSEIService abs = new AddressBookNoImplSEIServiceLocator();
               opts.setDefaultURL( abs.getAddressBookNoImplSEIAddress() );
               URL serviceURL = new URL(opts.getURL());
   
  -            AddressBook ab1 = null;
  +            AddressBookNoImplSEI ab1 = null;
               if (serviceURL == null) {
                   ab1 = abs.getAddressBookNoImplSEI();
               }
  @@ -148,14 +161,14 @@
               }
   
               System.err.println ("\n\nUsing proxy with session maintenance.");
  -            AddressBook ab2 = null;
  +            AddressBookNoImplSEI ab2 = null;
               if (serviceURL == null) {
                   ab2 = abs.getAddressBookNoImplSEI();
               }
               else {
                   ab2 = abs.getAddressBookNoImplSEI(serviceURL);
               }
  -            ((AddressBookSOAPBindingStub) ab2).setMaintainSession (true);
  +            ((AddressBookNoImplSEISoapBindingStub) ab2).setMaintainSession (true);
               ret = doit (ab2);
               if (ret == null) {
                   throw new Exception("session test expected non-null response, got "+ret);
  
  
  
  1.1                  xml-axis/java/test/wsdl/addrNoImplSEI/AddressBookNoImplSEISoapBindingImpl.java
  
  Index: AddressBookNoImplSEISoapBindingImpl.java
  ===================================================================
  /**
   * AddressBookNoImplSEISOAPBindingImpl.java
   *
   * This file was hand modified from the Emmitter generated code.
   */
  
  package test.wsdl.addrNoImplSEI;
  
  import java.util.Hashtable;
  import java.util.Map;
  
  // Don't implement the AddressBook interface
  public class AddressBookNoImplSEISoapBindingImpl {
      private Map addresses = new Hashtable();
  
      public void addEntry(java.lang.String name, test.wsdl.addrNoImplSEI.Address address)

          throws java.rmi.RemoteException, 
                 java.lang.IllegalArgumentException  // This should be accepted
      {
          if (address == null) {
              throw new java.lang.IllegalArgumentException(); 
          }
          this.addresses.put(name, address);
      }
      public test.wsdl.addrNoImplSEI.Address getAddressFromName(java.lang.String name) 
          throws java.rmi.RemoteException,
                 javax.xml.rpc.JAXRPCException // This should be accepted
      {
          return (test.wsdl.addrNoImplSEI.Address) this.addresses.get(name);
      }
  }
  
  
  

Mime
View raw message