Author: ema
Date: Fri Apr 27 00:22:53 2007
New Revision: 532998

URL: http://svn.apache.org/viewvc?view=rev&rev=532998
Log:
[CXF-594]Added portName flag for java2wsdl tool

Modified:
    
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml
    
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
    
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java

Modified: 
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml?view=diff&rev=532998&r1=532997&r2=532998
==============================================================================
--- 
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml
 (original)
+++ 
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml
 Fri Apr 27 00:22:53 2007
@@ -1,147 +1,155 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements. See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership. The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License. You may obtain a copy of the License at
- 
-  http://www.apache.org/licenses/LICENSE-2.0
- 
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied. See the License for the
-  specific language governing permissions and limitations
-  under the License.
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements. See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership. The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License. You may obtain a copy of the License at
+       
+       http://www.apache.org/licenses/LICENSE-2.0
+       
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied. See the License for the
+       specific language governing permissions and limitations
+       under the License.
 -->
 
 <!-- The xhtml namespace is for usage documentation -->
 <toolspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-         xmlns:xhtml="http://www.w3.org/TR/xhtml1/strict";
-         xsi:schemaLocation="http://www.xsume.com/Xutil/ToolSpecification 
http://www.xsume.com/schema/xutil/tool-specification.xsd";
-         xmlns="http://www.xsume.com/Xutil/ToolSpecification";
-         xmlns:ts="http://www.xsume.com/Xutil/ToolSpecification";>
-
-    <annotation> 
-Examples :
-
-java2wsdl org.apache.hello_world_soap_http.Greeter
-java2wsdl -cp ./tmp org.apache.hello_world_soap_http.Greeter
-java2wsdl -o hello.wsdl org.apache.hello_world_soap_http.Greeter
-java2wsdl -o hello.wsdl -t http://cxf.apache.org 
org.apache.hello_world_soap_http.Greeter
-    </annotation>
-    <usage>
-
-       <optionGroup id="options">
-           <option id="outputfile" maxOccurs="1">
-               <annotation>
-                           Specify the output wsdl file name
-               </annotation>
-               <switch>o</switch>
-               <associatedArgument placement="afterSpace">
-                   <annotation>output-file</annotation>
-               </associatedArgument>
-           </option>
-           
-        <option id="outputdir" maxOccurs="1">
-            <annotation>The directory in which the output files are 
placed</annotation>
-            <switch>d</switch>
-            <associatedArgument placement="afterSpace">
-                <annotation>output-directory</annotation>
-            </associatedArgument>
-        </option>
-                   
-           <option id="classpath" maxOccurs="1">
-               <annotation>
-                           Specify the SEI and types class search path of 
directories 
-                           and zip/jar files
-               </annotation>
-               <switch>cp</switch>
-               <associatedArgument placement="afterSpace">
-                   <annotation>class-path</annotation>
-               </associatedArgument>
-           </option>
-
-           <option id="soap12" maxOccurs="1">
-               <annotation>
-                   Specify to generate SOAP 1.2 binding
-               </annotation>
-               <switch>soap12</switch>
-           </option>
-
-           <option id="tns" maxOccurs="1">
-               <annotation>
-                           Specify the target namespace to use in the wsdl
-               </annotation>
-               <switch>t</switch>
-               <associatedArgument placement="afterSpace">
-                   <annotation>target-namespace</annotation>
-               </associatedArgument>
-           </option>
-           
-           <option id="servicename" maxOccurs="1">
-               <annotation>
-                           Specify the service name to use in the generated 
wsdl
-               </annotation>
-               <switch>servicename</switch>
-               <associatedArgument placement="afterSpace">
-                   <annotation>service-name</annotation>
-               </associatedArgument>
-           </option>
-           
-           <option id="createxsdimports" maxOccurs="1">
-               <annotation>
-                     Output schemas to separate files and use imports to load 
them instead of 
-                     inlining them into the wsdl.      
-               </annotation>
-               <switch>createxsdimports</switch>
-           </option>       
-             
-       </optionGroup>
-
-       <optionGroup id="common_options">
-           <option id="help" maxOccurs="1">
-               <annotation>
-                           Display detailed information for options.
-               </annotation>
-               <switch>h</switch>
-               <switch>?</switch>
-               <switch>help</switch>
-           </option>
-           
-           <option id="version">
-               <annotation>
-                           Display the version of the tool.
-               </annotation>
-               <switch>v</switch>
-           </option>
-
-           <option id="verbose">
-               <annotation>
-                           Verbose mode
-               </annotation>
-               <switch>verbose</switch>
-               <switch>V</switch>
-           </option>
-
-           <option id="quiet">
-               <annotation>
-                           Quiet mode
-               </annotation>
-               <switch>quiet</switch>
-               <switch>q</switch>
-           </option>
-
-
-       </optionGroup>
-
-       <argument id="classname" minOccurs="1" maxOccurs="1">
-                <annotation>
-                           SEI class name
-                </annotation>
-       </argument>
-    </usage>
+       xmlns:xhtml="http://www.w3.org/TR/xhtml1/strict";
+       xsi:schemaLocation="http://www.xsume.com/Xutil/ToolSpecification 
http://www.xsume.com/schema/xutil/tool-specification.xsd";
+       xmlns="http://www.xsume.com/Xutil/ToolSpecification";
+       xmlns:ts="http://www.xsume.com/Xutil/ToolSpecification";>
+
+       <annotation>
+               Examples :
+
+               java2wsdl org.apache.hello_world_soap_http.Greeter java2wsdl -cp
+               ./tmp org.apache.hello_world_soap_http.Greeter java2wsdl -o
+               hello.wsdl org.apache.hello_world_soap_http.Greeter java2wsdl -o
+               hello.wsdl -t http://cxf.apache.org
+               org.apache.hello_world_soap_http.Greeter
+       </annotation>
+       <usage>
+
+               <optionGroup id="options">
+                       <option id="outputfile" maxOccurs="1">
+                               <annotation>
+                                       Specify the output wsdl file name
+                               </annotation>
+                               <switch>o</switch>
+                               <associatedArgument placement="afterSpace">
+                                       <annotation>output-file</annotation>
+                               </associatedArgument>
+                       </option>
+
+                       <option id="outputdir" maxOccurs="1">
+                               <annotation>
+                                       The directory in which the output files 
are placed
+                               </annotation>
+                               <switch>d</switch>
+                               <associatedArgument placement="afterSpace">
+                                       
<annotation>output-directory</annotation>
+                               </associatedArgument>
+                       </option>
+
+                       <option id="classpath" maxOccurs="1">
+                               <annotation>
+                                       Specify the SEI and types class search 
path of
+                                       directories and zip/jar files
+                               </annotation>
+                               <switch>cp</switch>
+                               <associatedArgument placement="afterSpace">
+                                       <annotation>class-path</annotation>
+                               </associatedArgument>
+                       </option>
+
+                       <option id="soap12" maxOccurs="1">
+                               <annotation>
+                                       Specify to generate SOAP 1.2 binding
+                               </annotation>
+                               <switch>soap12</switch>
+                       </option>
+
+                       <option id="tns" maxOccurs="1">
+                               <annotation>
+                                       Specify the target namespace to use in 
the wsdl
+                               </annotation>
+                               <switch>t</switch>
+                               <associatedArgument placement="afterSpace">
+                                       
<annotation>target-namespace</annotation>
+                               </associatedArgument>
+                       </option>
+
+                       <option id="servicename" maxOccurs="1">
+                               <annotation>
+                                       Specify the service name to use in the 
generated
+                                       wsdl
+                               </annotation>
+                               <switch>servicename</switch>
+                               <associatedArgument placement="afterSpace">
+                                       <annotation>service-name</annotation>
+                               </associatedArgument>
+                       </option>
+
+                       <option id="port" maxOccurs="1">
+                               <annotation>
+                                       Specify the port name to use in the 
generated wsdl
+                               </annotation>
+                               <switch>portname</switch>
+                               <associatedArgument placement="afterSpace">
+                                       <annotation>port-name</annotation>
+                               </associatedArgument>
+                       </option>
+
+                       <option id="createxsdimports" maxOccurs="1">
+                               <annotation>
+                                       Output schemas to separate files and 
use imports to
+                                       load them instead of inlining them into 
the wsdl.
+                               </annotation>
+                               <switch>createxsdimports</switch>
+                       </option>
+
+               </optionGroup>
+
+               <optionGroup id="common_options">
+                       <option id="help" maxOccurs="1">
+                               <annotation>
+                                       Display detailed information for 
options.
+                               </annotation>
+                               <switch>h</switch>
+                               <switch>?</switch>
+                               <switch>help</switch>
+                       </option>
+
+                       <option id="version">
+                               <annotation>
+                                       Display the version of the tool.
+                               </annotation>
+                               <switch>v</switch>
+                       </option>
+
+                       <option id="verbose">
+                               <annotation>Verbose mode</annotation>
+                               <switch>verbose</switch>
+                               <switch>V</switch>
+                       </option>
+
+                       <option id="quiet">
+                               <annotation>Quiet mode</annotation>
+                               <switch>quiet</switch>
+                               <switch>q</switch>
+                       </option>
+
+
+               </optionGroup>
+
+               <argument id="classname" minOccurs="1" maxOccurs="1">
+                       <annotation>SEI class name</annotation>
+               </argument>
+       </usage>
 </toolspec>

Modified: 
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java?view=diff&rev=532998&r1=532997&r2=532998
==============================================================================
--- 
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
 (original)
+++ 
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
 Fri Apr 27 00:22:53 2007
@@ -35,6 +35,7 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.Processor;
 import org.apache.cxf.tools.common.ToolConstants;
@@ -70,6 +71,13 @@
         if (context.containsKey(ToolConstants.CFG_TNS)) {
             String ns = (String)context.get(ToolConstants.CFG_TNS);
             service.setTargetNamespace(ns);
+        }
+        
+        if (context.containsKey(ToolConstants.CFG_PORT)) {
+            String portName = (String)context.get(ToolConstants.CFG_PORT);
+            EndpointInfo einfo = service.getEndpoints().iterator().next();
+            QName qn = new QName(einfo.getName().getNamespaceURI(), portName); 
+            einfo.setName(qn);
         }
         generator.setServiceModel(service);
         generator.generate(output);

Modified: 
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?view=diff&rev=532998&r1=532997&r2=532998
==============================================================================
--- 
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
 (original)
+++ 
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
 Fri Apr 27 00:22:53 2007
@@ -22,6 +22,7 @@
 import java.io.File;
 
 import javax.wsdl.Definition;
+import javax.wsdl.Port;
 import javax.wsdl.Service;
 import javax.xml.namespace.QName;
 
@@ -34,6 +35,7 @@
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.WSDLConstants;
+import org.apache.cxf.tools.java2wsdl.JavaToWSDL;
 import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
 import org.apache.cxf.tools.wsdlto.core.FrontEndProfile;
 import org.apache.cxf.tools.wsdlto.core.PluginLoader;
@@ -156,24 +158,35 @@
         
         String tns = "http://apache.org/sepecifiedTns";;
         String serviceName = "cxfService";
+        String portName = "cxfPort";
 
         System.setProperty("java.class.path", "");
         
-        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + 
"/doc_lit_classpath.wsdl");
-        env.put(ToolConstants.CFG_CLASSNAME, 
"org.apache.cxf.classpath.Greeter");
-        env.put(ToolConstants.CFG_TNS, tns);
-        env.put(ToolConstants.CFG_CLASSPATH, classFile.getCanonicalPath());
-        env.put(ToolConstants.CFG_SERVICENAME, serviceName);
-        processor.setEnvironment(env);
-        processor.process();
-        
-        File wsdlFile = new File(output, "doc_lit_classpath.wsdl");
+//      test flag
+        String[] args = new String[] {"-o",
+                                      "java2wsdl.wsdl",
+                                      "-cp",
+                                      classFile.getCanonicalPath(),
+                                      "-t",
+                                      tns,
+                                      "-servicename",
+                                      serviceName,
+                                      "-portname",
+                                      portName,
+                                      "-soap12",
+                                      "-d",
+                                      output.getPath(),
+                                      "org.apache.cxf.classpath.Greeter"};
+        JavaToWSDL.main(args);
+        File wsdlFile = new File(output, "java2wsdl.wsdl");
         assertTrue("Generate Wsdl Fail", wsdlFile.exists());
-
         Definition def = wsdlHelper.getDefinition(wsdlFile);
         Service wsdlService = def.getService(new QName(tns, serviceName));
         assertNotNull("Generate WSDL Service Error", wsdlService);
-
+        
+        Port wsdlPort = wsdlService.getPort(portName);
+        assertNotNull("Generate service port error ", wsdlPort);
+        
     }
 
     @Test
@@ -211,4 +224,5 @@
         String expectedFile = 
getClass().getResource("expected/my_hello_soap12.wsdl").getFile();
         assertFileEquals(new File(expectedFile), new File(output, 
"my_hello_soap12.wsdl"));
     }
+        
 }


Reply via email to