You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2005/09/14 12:45:47 UTC

svn commit: r280819 - in /webservices/axis2/trunk/java/modules/wsdl: src/org/apache/axis2/wsdl/codegen/ src/org/apache/axis2/wsdl/codegen/emitter/ src/org/apache/axis2/wsdl/codegen/writer/ src/org/apache/axis2/wsdl/template/java/ test-resources/ test/o...

Author: ajith
Date: Wed Sep 14 03:45:11 2005
New Revision: 280819

URL: http://svn.apache.org/viewcvs?rev=280819&view=rev
Log:
1.Fixed a minor error caused by a missing Service.
2.Fixed the template to suit the new change in contexts
3.Added some new tests to the WSDL2JavaTest.java
4.Added a configurable file extension to the config

Added:
    webservices/axis2/trunk/java/modules/wsdl/test-resources/headers.wsdl
    webservices/axis2/trunk/java/modules/wsdl/test-resources/no-service.wsdl
Modified:
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ServiceXMLWriter.java
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
    webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/codegen/WSDL2JavaTest.java

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties?rev=280819&r1=280818&r2=280819&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties Wed Sep 14 03:45:11 2005
@@ -45,6 +45,8 @@
 java.dbsupporter.xmlbeans.template=org.apache.axis2.wsdl.codegen.writer.DatabindingSupportClassWriter,/org/apache/axis2/wsdl/template/java/XMLBeansSupporterTemplate.xsl
 java.dbsupporter.jaxb.template=org.apache.axis2.wsdl.codegen.writer.DatabindingSupportClassWriter,/org/apache/axis2/wsdl/template/java/XMLBeansSupporterTemplate.xsl
 java.dbsupporter.default.template=org.apache.axis2.wsdl.codegen.writer.DatabindingSupportClassWriter,/org/apache/axis2/wsdl/template/java/DefaultDataBindingSupporterTemplate.xsl
+# file extension for generated files from this language
+java.filename.extension=java
 #
 # ##################################################################################################################
 # C sharp section - Templates
@@ -55,4 +57,5 @@
 c-sharp.skeleton.template=org.apache.axis2.wsdl.codegen.writer.SkeletonWriter,/org/apache/axis2/wsdl/template/csharp/SkeletonTemplate.xsl
 c-sharp.testclass.template=org.apache.axis2.wsdl.codegen.writer.TestClassWriter,/org/apache/axis2/wsdl/template/csharp/TestClassTemplate.xsl
 c-sharp.service.template=org.apache.axis2.wsdl.codegen.writer.ServiceXMLWriter,/org/apache/axis2/wsdl/template/general/ServiceXMLTemplate.xsl
-c-sharp.message.receiver.template=org.apache.axis2.wsdl.codegen.writer.MessageReceiverWriter,/org/apache/axis2/wsdl/template/csharp/MessageReceiverTemplate.xsl
\ No newline at end of file
+c-sharp.message.receiver.template=org.apache.axis2.wsdl.codegen.writer.MessageReceiverWriter,/org/apache/axis2/wsdl/template/csharp/MessageReceiverTemplate.xsl
+c-sharp.filename.extension=cs
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java?rev=280819&r1=280818&r2=280819&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java Wed Sep 14 03:45:11 2005
@@ -1054,11 +1054,11 @@
         if (list!=null && !list.isEmpty()){
             int count = list.size();
             for (int i = 0; i < count; i++) {
-              qname = (QName)list.get(i);
-              elt = doc.createElement("name") ;
-              addAttribute(doc,"ns-url",qname.getNamespaceURI(),elt);
-              addAttribute(doc,"localName",qname.getLocalPart(),elt);
-              root.appendChild(elt);
+                qname = (QName)list.get(i);
+                elt = doc.createElement("name") ;
+                addAttribute(doc,"ns-url",qname.getNamespaceURI(),elt);
+                addAttribute(doc,"localName",qname.getLocalPart(),elt);
+                root.appendChild(elt);
             }
         }
 
@@ -1073,8 +1073,11 @@
     protected Document createDOMDocumentForInterfaceImplementation(
             WSDLBinding binding, WSDLService service) {
         WSDLInterface boundInterface = binding.getBoundInterface();
+        HashMap endpoints = new HashMap(1);
+        if (service!=null){
+            endpoints = service.getEndpoints();
+        }
 
-        HashMap endpoints = service.getEndpoints();
         Document doc = getEmptyDocument();
         Element rootElement = doc.createElement("class");
         addAttribute(doc,
@@ -1112,7 +1115,7 @@
         //load the operations
         loadOperations(boundInterface, doc, rootElement, binding);
         doc.appendChild(rootElement);
-       
+
         return doc;
 
 

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java?rev=280819&r1=280818&r2=280819&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java Wed Sep 14 03:45:11 2005
@@ -42,6 +42,7 @@
     protected String language = ConfigPropertyFileLoader.getDefaultLanguage(); //default would java
 
     protected static final String TEMPLATE_SUFFIX = ".template";
+    protected static final String EXTENSION_SUFFIX = ".extension";
     protected static final String SEPERATOR_STRING = ",";
 
     /**
@@ -115,8 +116,31 @@
         File outputFile = FileWriter.createClassFile(outputFileLocation,
                 packageName,
                 fileName,
-                language);
+                getFileExtensionForLanguage(language));
         this.stream = new FileOutputStream(outputFile);
+    }
+
+    /**
+     * Find the file name extension
+     * @param language
+     * @return
+     */
+    protected String getFileExtensionForLanguage(String language){
+        Map languageSpecificPropertyMap = (Map)ConfigPropertyFileLoader.getLanguageSpecificPropertiesMap().get(this.language);
+        Iterator keys = languageSpecificPropertyMap.keySet().iterator();
+        String key;
+        String extension = null;
+        while (keys.hasNext()) {
+            //check for template entries
+            key = keys.next().toString();
+            if (key.endsWith(EXTENSION_SUFFIX)){
+                extension = languageSpecificPropertyMap.get(key).toString();
+                //add a . to the front
+                extension = "." + extension;
+            }
+        }
+
+        return extension;
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ServiceXMLWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ServiceXMLWriter.java?rev=280819&r1=280818&r2=280819&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ServiceXMLWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ServiceXMLWriter.java Wed Sep 14 03:45:11 2005
@@ -41,7 +41,7 @@
     public void createOutFile(String packageName, String fileName) throws Exception {
         File outputFile = FileWriter.createClassFile(outputFileLocation,
                 packageName,
-                "service",
+                "services",
                 ".xml");
         this.stream = new FileOutputStream(outputFile);
     }

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=280819&r1=280818&r2=280819&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl Wed Sep 14 03:45:11 2005
@@ -41,8 +41,8 @@
 			this.toEPR = new org.apache.axis2.addressing.EndpointReference(targetEndpoint);
 		    //creating the configuration
            _configurationContext = new org.apache.axis2.context.ConfigurationContextFactory().buildClientConfigurationContext(axis2Home);
-           _configurationContext.getAxisConfiguration().addService(_service);
-           _serviceContext = _configurationContext.createServiceContext(_service.getName());
+           //_configurationContext.getAxisConfiguration().addService(_service);
+           _serviceContext =_service.getParent().getServiceGroupContext(_configurationContext).getServiceContext(_service.getName().getLocalPart());
         <!--  Set the soap version depending on the binding. Default is 1.1 so don't set anything for that case-->
         <xsl:if test="$soapVersion='1.2'">
             //Set the soap version

Added: webservices/axis2/trunk/java/modules/wsdl/test-resources/headers.wsdl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/test-resources/headers.wsdl?rev=280819&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/test-resources/headers.wsdl (added)
+++ webservices/axis2/trunk/java/modules/wsdl/test-resources/headers.wsdl Wed Sep 14 03:45:11 2005
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/" xmlns:types="http://soapinterop.org/xsd" targetNamespace="http://soapinterop.org/">
+  <types>
+    <s:schema elementFormDefault="qualified" targetNamespace="http://soapinterop.org/xsd">
+      <s:element name="echoStringParam" type="s:string"/>
+         
+      <s:element name="echoStringReturn" type="s:string"/>
+
+      <s:element name="Header1" type="types:Header1"/>
+      <s:complexType name="Header1">
+        <s:sequence>
+          <s:element name="string" type="s:string"/>
+          <s:element name="int" type="s:int"/>
+        </s:sequence>
+	<s:anyAttribute/>
+      </s:complexType>
+      <s:element name="Header2" type="types:Header2"/>
+      <s:complexType name="Header2">
+        <s:sequence>
+          <s:element name="int" type="s:int"/>
+          <s:element name="string" type="s:string"/>
+        </s:sequence>
+	<s:anyAttribute/>
+      </s:complexType>
+    </s:schema>
+  </types>
+  <message name="echoString">
+        <part element="types:echoStringParam" name="a"/>
+    </message>
+    <message name="echoStringResponse">
+        <part element="types:echoStringReturn" name="result"/>
+    </message>
+  <message name="Header1">
+    <part name="Header1" element="types:Header1"/>
+  </message>
+  <message name="Header2">
+    <part name="Header2" element="types:Header2"/>
+  </message>
+  <portType name="RetHeaderPortType">
+    <operation name="echoString">
+      <input message="tns:echoString"/>
+      <output message="tns:echoStringResponse"/>
+    </operation>
+  </portType>
+  <binding name="RetHeaderBinding" type="tns:RetHeaderPortType">
+    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+    <operation name="echoString">
+      <soap:operation soapAction="http://soapinterop.org/" style="document"/>
+      <input>
+        <soap:body use="literal"/>
+        <soap:header message="tns:Header1" part="Header1" use="literal"/>
+        <soap:header message="tns:Header2" part="Header2" use="literal"/>
+      </input>
+      <output>
+        <soap:body use="literal"/>
+      </output>
+    </operation>
+  </binding>
+  <service name="RetHeaderService">
+    <port name="RetHeaderPort" binding="tns:RetHeaderBinding">
+      <soap:address location="http://soapinterop.java.sun.com:80/round3/groupf/headers"/>
+    </port>
+  </service>
+</definitions>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/wsdl/test-resources/no-service.wsdl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/test-resources/no-service.wsdl?rev=280819&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/test-resources/no-service.wsdl (added)
+++ webservices/axis2/trunk/java/modules/wsdl/test-resources/no-service.wsdl Wed Sep 14 03:45:11 2005
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
+  targetNamespace="http://www.gridforum.org/cddlm/deployapi/2005/02/wsdl"
+  xmlns:tns="http://www.gridforum.org/cddlm/deployapi/2005/02/wsdl"
+  xmlns:api="http://www.gridforum.org/cddlm/deployapi/2005/02"
+  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+  xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+  xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing"
+  >
+  
+   <wsdl:types>
+    <xsd:schema targetNamespace="http://www.gridforum.org/cddlm/deployapi/2005/02"
+      xmlns="http://www.gridforum.org/cddlm/deployapi/2005/02"
+      elementFormDefault="qualified">
+    
+    
+       <xsd:complexType name="unboundedXMLAnyNamespace">
+        <xsd:sequence>
+          <xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+      </xsd:complexType>
+       
+      <xsd:element name="createRequest">
+        <xsd:complexType>
+          <xsd:annotation>
+            <xsd:documentation>
+              This is our request to create a system
+            </xsd:documentation>
+          </xsd:annotation>
+          <xsd:sequence>
+            <xsd:element name="hostname" type="xsd:string" minOccurs="0"/>
+          </xsd:sequence>
+        </xsd:complexType>
+      </xsd:element>
+      <!-- ============================================================= -->
+      <!-- ============================================================= -->
+      <xsd:element name="createResponse">
+        <xsd:complexType>
+          <xsd:annotation>
+            <xsd:documentation>
+              This is our deployment response.
+              It consists of a reference to the system, 
+              which can then be used directly
+            </xsd:documentation>
+          </xsd:annotation>
+          <xsd:sequence>
+            <xsd:element name="ResourceId" type="xsd:anyURI"/>
+            <xsd:element name="systemReference" type="api:unboundedXMLAnyNamespace"/>
+          </xsd:sequence>
+        </xsd:complexType>
+      </xsd:element>
+      
+    </xsd:schema>
+    
+   </wsdl:types>
+  
+   
+  <wsdl:message name="createRequest">
+    <wsdl:part element="api:createRequest" name="createRequest"/>
+  </wsdl:message>
+
+  <wsdl:message name="createResponse">
+    <wsdl:part element="api:createResponse" name="createResponse"/>
+  </wsdl:message>
+  
+ <wsdl:portType name="PortalEPR"
+    >
+    
+    <!-- create -->
+    <wsdl:operation name="Create">
+      <wsdl:input message="tns:createRequest" name="CreateRequest"/>
+      <wsdl:output message="tns:createResponse" name="CreateResponse"/>
+      <wsdl:fault name="DeploymentFault"
+        message="tns:DeploymentFault"/>
+    </wsdl:operation>
+    
+    </wsdl:portType>
+  
+  <wsdl:binding name="PortalEPRBinding" type="tns:PortalEPR">
+    <wsdlsoap:binding style="document"
+      transport="http://schemas.xmlsoap.org/soap/http"/>
+  <wsdl:operation name="Create">
+      <wsdlsoap:operation soapAction="" style="document"/>
+      <wsdl:input name="CreateRequest">
+        <wsdlsoap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="CreateResponse">
+        <wsdlsoap:body use="literal"/>
+      </wsdl:output>
+<!--       <wsdl:fault name="DeploymentFault">
+        <wsdlsoap:fault name="DeploymentFault" use="literal"/>
+      </wsdl:fault> -->
+    </wsdl:operation>
+    
+  </wsdl:binding>
+      
+  </wsdl:definitions>

Modified: webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/codegen/WSDL2JavaTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/codegen/WSDL2JavaTest.java?rev=280819&r1=280818&r2=280819&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/codegen/WSDL2JavaTest.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/codegen/WSDL2JavaTest.java Wed Sep 14 03:45:11 2005
@@ -98,6 +98,29 @@
         }
     }
 
+    /**
+     * Test for the WSDL that's missing a service
+     */
+    public void testCodeGenerationNoService(){
+
+        try {
+            generateAndCompile("no-service.wsdl", OUTPUT_LOCATION_BASE+OUTPUT_LOCATION_PREFIX+folderCount++);
+        } catch (CodeGenerationException e) {
+            fail("Exception while code generation test!"+ e.getMessage());
+        }
+    }
+
+     /**
+     * Test for the Headers
+     */
+    public void testCodeGenerationHeaders(){
+
+        try {
+            generateAndCompile("headers.wsdl", OUTPUT_LOCATION_BASE+OUTPUT_LOCATION_PREFIX+folderCount++);
+        } catch (CodeGenerationException e) {
+            fail("Exception while code generation test!"+ e.getMessage());
+        }
+    }
 
     /**
      * Test for the ping WSDL