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 Java2WsdlAntTask.java Wsdl2javaTestSuite.xml
Date Wed, 05 Dec 2001 22:04:06 GMT
scheu       01/12/05 14:04:06

  Modified:    java/src/org/apache/axis/wsdlgen Emitter.java Java2Wsdl.java
                        Types.java
               java/test/sequence SequenceTest.wsdl
                        SequenceTestServiceTestCase.java
               java/test/wsdl Wsdl2javaTestSuite.xml
  Added:       java/test/wsdl Java2WsdlAntTask.java
  Removed:     java/test/sequence SequenceTestSOAPBindingImpl.java
  Log:
  Added Java2Wsdl Ant Task
  Modified SequenceTest to do wsdl->java->wsdl->java->test
  Minor modifications of Java2Wsdl
  
  Enjoy
  
  Revision  Changes    Path
  1.14      +5 -3      xml-axis/java/src/org/apache/axis/wsdlgen/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdlgen/Emitter.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Emitter.java	2001/12/04 13:10:31	1.13
  +++ Emitter.java	2001/12/05 22:04:06	1.14
  @@ -352,7 +352,7 @@
       private Binding writeBinding(Definition def, boolean add) throws Exception {
           Binding binding = def.createBinding();
           binding.setUndefined(false);
  -        binding.setQName(new javax.wsdl.QName(intfNS, clsName + "SoapBinding"));
  +        binding.setQName(new javax.wsdl.QName(intfNS, getServiceName() + "SoapBinding"));
   
           SOAPBinding soapBinding = new SOAPBindingImpl();
           soapBinding.setStyle("rpc");
  @@ -383,8 +383,10 @@
           Port port = def.createPort();
   
           port.setBinding(binding);
  -        port.setName(clsName + "Port");
   
  +        // Probably should use the end of the location Url
  +        port.setName(getServiceName());
  +
           SOAPAddress addr = new SOAPAddressImpl();
           addr.setLocationURI(locationUrl);
   
  @@ -404,7 +406,7 @@
           PortType portType = def.createPortType();
           portType.setUndefined(false);
   
  -        portType.setQName(new javax.wsdl.QName(intfNS, clsName + "PortType"));
  +        portType.setQName(new javax.wsdl.QName(intfNS, getServiceName() + "PortType"));
   
           /** @todo should introduce allowInterfaces, to publish all methods from a interface
*/
           /** @todo if allowedMethods is specified always look for inherited methods as well??
*/
  
  
  
  1.8       +1 -1      xml-axis/java/src/org/apache/axis/wsdlgen/Java2Wsdl.java
  
  Index: Java2Wsdl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdlgen/Java2Wsdl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Java2Wsdl.java	2001/12/02 22:45:28	1.7
  +++ Java2Wsdl.java	2001/12/05 22:04:06	1.8
  @@ -114,7 +114,7 @@
                   CLOptionDescriptor.ARGUMENT_REQUIRED,
                   LOCATION_OPT,
                   "service location"),
  -        new CLOptionDescriptor("service name",
  +        new CLOptionDescriptor("service",
                   CLOptionDescriptor.ARGUMENT_REQUIRED,
                   SERVICE_NAME_OPT,
                   "service name"),
  
  
  
  1.8       +2 -1      xml-axis/java/src/org/apache/axis/wsdlgen/Types.java
  
  Index: Types.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdlgen/Types.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Types.java	2001/12/05 19:45:41	1.7
  +++ Types.java	2001/12/05 22:04:06	1.8
  @@ -204,7 +204,8 @@
               // Get the QName from the registry, or create our own.
               qName = reg.getTypeQName(type);
               if (qName == null) {
  -                String ns = namespaces.getCreate(type.getName().substring(0, type.getName().lastIndexOf('.')));
  +                String ns = namespaces.getCreate(
  +                  type.getName().substring(0, type.getName().lastIndexOf('.')));
                   String pre = namespaces.getCreatePrefix(ns);
                   String localPart = type.getName().substring(type.getName().lastIndexOf('.')
+ 1);
                   localPart = localPart.replace('$', '_');
  
  
  
  1.2       +4 -4      xml-axis/java/test/sequence/SequenceTest.wsdl
  
  Index: SequenceTest.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/sequence/SequenceTest.wsdl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SequenceTest.wsdl	2001/11/13 18:38:17	1.1
  +++ SequenceTest.wsdl	2001/12/05 22:04:06	1.2
  @@ -40,7 +40,7 @@
     </message>
   
     <!-- port type declns -->
  -  <portType name="SequenceTest">
  +  <portType name="SequenceTestPortType">
       <operation name="testSequence">
         <input message="tns:testSequenceRequest"/>
         <output message="tns:testSequenceResponse"/>
  @@ -48,7 +48,7 @@
     </portType>
   
     <!-- binding declns -->
  -  <binding name="SequenceTestSOAPBinding" type="tns:SequenceTest">
  +  <binding name="SequenceTestSoapBinding" type="tns:SequenceTestPortType">
       <soap:binding style="rpc"
                     transport="http://schemas.xmlsoap.org/soap/http"/>
       <operation name="testSequence">
  @@ -67,8 +67,8 @@
     </binding>
   
     <!-- service decln -->
  -  <service name="SequenceTestService">
  -    <port name="SequenceTest" binding="tns:SequenceTestSOAPBinding">
  +  <service name="SequenceTest">
  +    <port name="SequenceTest" binding="tns:SequenceTestSoapBinding">
         <soap:address location="http://localhost:8080/axis/services/SequenceTest"/>
       </port>
     </service>
  
  
  
  1.2       +2 -1      xml-axis/java/test/sequence/SequenceTestServiceTestCase.java
  
  Index: SequenceTestServiceTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/sequence/SequenceTestServiceTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SequenceTestServiceTestCase.java	2001/11/13 18:38:18	1.1
  +++ SequenceTestServiceTestCase.java	2001/12/05 22:04:06	1.2
  @@ -12,7 +12,8 @@
       }
   
       public void testSequenceTest() {
  -        test.sequence.SequenceTest binding = new SequenceTestService().getSequenceTest();
  +        test.sequence.SequenceTestPortType binding =
  +            new SequenceTest().getSequenceTest();
           assertTrue("binding is null", binding != null);
           try {
               int value = -3;
  
  
  
  1.30      +42 -0     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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Wsdl2javaTestSuite.xml	2001/12/05 21:41:42	1.29
  +++ Wsdl2javaTestSuite.xml	2001/12/05 22:04:06	1.30
  @@ -16,6 +16,11 @@
         <classpath refid="test-classpath" />
     </taskdef>
   
  +  <taskdef name="java2wsdl" 
  +           classname="test.wsdl.Java2WsdlAntTask">
  +      <classpath refid="test-classpath" />
  +  </taskdef>
  +
     <target name="main">
       <!-- Use this to check the classpath if the ANT Task fails... -->
       <!--
  @@ -48,6 +53,7 @@
       </wsdl2java>
   
       <!-- Sequence Test -->
  +    <!-- Generate Java From WSDL -->
       <wsdl2java url="test/sequence/SequenceTest.wsdl"
                  output="build/work"
                  deployscope="session"
  @@ -58,6 +64,40 @@
                  testcase="no">
           <mapping namespace="urn:SequenceTest2" package="test.sequence"/>
       </wsdl2java>
  +    <!-- Copy modified files to work directory -->
  +    <copy todir="${build.dir}/work/test" overwrite="yes">
  +      <fileset dir="${test.dir}">
  +        <include name="sequence/SequenceInfo.java"/>
  +      </fileset>
  +    </copy>
  +    <!-- Compile Java -->
  +    <echo message="${build.dir} ${build.dest}"/>
  +    <javac srcdir="${build.dir}/work" destdir="${build.dest}"
  +           debug="${debug}">
  +      <classpath refid="test-classpath" />
  +      <include name="test/sequence/**.java" />
  +      <exclude name="test/sequence/*TestCase.java" />
  +      <exclude name="test/sequence/*Impl.java" />
  +    </javac>
  +    <!-- Now create a WSDL file from the Java classes -->
  +    <java2wsdl output="build/work/test/sequence/SequenceTest.wsdl"
  +               className= "test.sequence.SequenceTestPortType"
  +               service= "SequenceTest"
  +               namespace="urn:SequenceTest2"
  +               location="http://localhost:8080/axis/services/SequenceTest">
  +        <mapping namespace="urn:SequenceTest2" package="test.sequence"/>
  +    </java2wsdl>
  +    <!-- Recreate Java files from the new WSDL -->
  +    <wsdl2java url="build/work/test/sequence/SequenceTest.wsdl"
  +               output="build/work"
  +               deployscope="session"
  +               skeleton="yes"
  +               messagecontext="no"
  +               noimports="no"
  +               verbose="no"
  +               testcase="no">
  +        <mapping namespace="urn:SequenceTest2" package="test.sequence"/>
  +    </wsdl2java>
   
       <!-- ArrayTest Test -->
       <wsdl2java url="test/arrays/ArrayTest.wsdl"
  @@ -322,6 +362,7 @@
       </wsdl2java>
       
       <!-- Check to make sure we map XML names that are illegal Java correctly -->
  +    <!--
       <wsdl2java url="test/wsdl/names/JavaNames.wsdl"
                  output="build/work"
                  deployscope="none"
  @@ -332,6 +373,7 @@
                  testcase="yes">
           <mapping namespace="http://test.com/reference" package="test.filegen"/>
       </wsdl2java>
  +    -->
     </target>
   </project>
   
  
  
  
  1.1                  xml-axis/java/test/wsdl/Java2WsdlAntTask.java
  
  Index: Java2WsdlAntTask.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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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;
  
  import org.apache.axis.wsdlgen.Emitter;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.Task;
  
  import java.util.HashMap;
  
  /**
   * Simple Ant task for running Java2Wsdl utility. 
   *
   * @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class Java2WsdlAntTask extends Task
  {
      private String namespace = "";
      private HashMap namespaceMap = new HashMap();
      private String location = "";
      private String output = "." ;
      private String className = "." ;
      private String service = null ;
  
      // The method executing the task
      public void execute() throws BuildException {
          try {
              log("Running Java2WsdlAntTask with parameters:", Project.MSG_VERBOSE);
              log("\tnamespace:" + namespace, Project.MSG_VERBOSE);
              log("\tPkgtoNS:" + namespaceMap, Project.MSG_VERBOSE);
              log("\tlocation:" + location, Project.MSG_VERBOSE);
              log("\toutput:" + output, Project.MSG_VERBOSE);
              log("\tclassName:" + className, Project.MSG_VERBOSE);
              
              // Instantiate the emitter
              Emitter emitter = new Emitter();
  
              if (!namespaceMap.isEmpty()) {
                  emitter.setNamespaceMap(namespaceMap);
              }
              if (service != null)
                  emitter.setServiceName(service);
              emitter.setCls(className, "");
              emitter.setIntfNamespace(namespace);
              emitter.setLocationUrl(location);
              emitter.emit(output, Emitter.MODE_ALL);
          } catch (Throwable t) {
              throw new BuildException("Error while running " + getClass().getName(), t);

          }
      }
  
      // The setter for the "output" attribute
      public void setOutput(String parameter) {
          this.output = parameter;
      }
  
      // The setter for the "location" attribute
      public void setLocation(String parameter) {
          this.location = parameter;
      }
  
      // The setter for the "className" attribute
      public void setClassName(String parameter) {
          this.className = parameter;
      }
  
      // The setter for the "service" attribute
      public void setService(String parameter) {
          this.service = parameter;
      }
  
      // The setter for the "namespace" attribute
      public void setNamespace(String parameter) {
          this.namespace = parameter;
      }
  
      /** the command arguments */
      public Mapping createMapping() {
          Mapping pkg = new Mapping();
          return pkg;
      }
  
      /**
       * Used for nested package definitions.
       */
      public class Mapping {
          private String namespace = null;
          private String packageName = null;
  
          public void setNamespace(String value) {
              namespace = value;
              if(namespace != null && packageName != null) {
                  namespaceMap.put(packageName,namespace);
                  namespace = null; 
                  packageName = null;
              }
          }
  
          public void setPackage(String value) {
              packageName = value;
              if(namespace != null && packageName != null) {
                  namespaceMap.put(packageName,namespace);
                  namespace = null;
                  packageName = null;
              }
          }
      }
  }
  
  
  
  
  

Mime
View raw message