You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by mm...@apache.org on 2006/11/20 10:17:15 UTC

svn commit: r477118 - in /incubator/cxf/trunk: rt/core/src/main/java/org/apache/cxf/interceptor/ tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/ tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/ tools/java2...

Author: mmao
Date: Mon Nov 20 01:17:10 2006
New Revision: 477118

URL: http://svn.apache.org/viewvc?view=rev&rev=477118
Log:
CXF-254
* Specify the default port number in wsdl generation from java2wsdl, and use the service name as the context name
* If the SEI has no BindingType annotation, 
   we should allow the method to alter the style value of the binding annotation instead of use the default value.
* Make the message more sense
* Unit tests

Added:
    incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/
    incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/
    incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/Hello.java   (with props)
Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedInInterceptor.java
    incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/ServiceGenerator.java
    incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/Messages.properties
    incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DocBareMethodProcessor.java
    incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DocWrapperMethodProcessor.java
    incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/RPCMethodProcessor.java
    incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedInInterceptor.java?view=diff&rev=477118&r1=477117&r2=477118
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedInInterceptor.java Mon Nov 20 01:17:10 2006
@@ -51,7 +51,7 @@
 
     public void handleMessage(Message message) {
         if (isGET(message) && message.getContent(List.class) != null) {
-            LOG.info("XMLMessageInInterceptor skipped in HTTP GET method");
+            LOG.info("WrappedInInterceptor skipped in HTTP GET method");
             return;
         }
         

Modified: incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/ServiceGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/ServiceGenerator.java?view=diff&rev=477118&r1=477117&r2=477118
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/ServiceGenerator.java (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/ServiceGenerator.java Mon Nov 20 01:17:10 2006
@@ -27,14 +27,14 @@
 import javax.wsdl.extensions.ExtensionRegistry;
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.common.WSDLConstants;
 import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
 import org.apache.cxf.tools.common.model.WSDLModel;
 import org.apache.cxf.tools.util.SOAPBindingUtil;
 
-public class ServiceGenerator {
-    private static final String ADDRESS_URI = "http://localhost/changme";
+public class ServiceGenerator {    
     private WSDLModel wmodel;
     private Definition definition;
     private ExtensionRegistry extensionRegistry;
@@ -50,6 +50,14 @@
         generate(false);
     }
     
+    private String getAddressName() {
+        String contextName = wmodel.getServiceName();
+        if (StringUtils.isEmpty(contextName)) {
+            contextName = "changeme";
+        }
+        return "http://localhost:9000/" + contextName;
+    }
+    
     public void generate(boolean isSOAP12) {
         Service service = definition.createService();
         service.setQName(new QName(WSDLConstants.WSDL_PREFIX, wmodel.getServiceName()));
@@ -62,7 +70,7 @@
         SoapAddress soapAddress = null;
         try {
             soapAddress = SOAPBindingUtil.createSoapAddress(extensionRegistry, isSOAP12);
-            soapAddress.setLocationURI(ADDRESS_URI);
+            soapAddress.setLocationURI(getAddressName());
         } catch (WSDLException e) {
             throw new ToolException(e.getMessage(), e);
         }

Modified: incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/Messages.properties?view=diff&rev=477118&r1=477117&r2=477118
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/Messages.properties (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/Messages.properties Mon Nov 20 01:17:10 2006
@@ -23,7 +23,7 @@
 PART_ALREADY_EXIST = Follwoing part already exist : {0} 
 ENCODED_USE_NOT_SUPPORTED = Encoded use is not supported in java2wsdl tool
 CANNOT_CREATE_SCHEMA_FILE = Can not create schema file
-SOAPUSESTYLE_PARAMETERSTYLE_ERROR = {0} : soapbinding use style and parameter style should be doc-wrapped/rpc-bare/doc-bare
+SOAPUSESTYLE_PARAMETERSTYLE_ERROR = {0} : soapbinding use-style and parameter style should be doc-lit-wrapped/rpc-lit/doc-lit-bare
 SEI_CLASS_NO_WEBSERVICE_ANNOTATED = SEI class should must annotated with @Webservice
 SEI_INTERFACE_NO_WEBSERVICE_ANNOTATED = SEI interface must be annotated with @Webservice
 SEI_CLASS_HASNO_PACKAGE = SEI class must be in a package

Modified: incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DocBareMethodProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DocBareMethodProcessor.java?view=diff&rev=477118&r1=477117&r2=477118
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DocBareMethodProcessor.java (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DocBareMethodProcessor.java Mon Nov 20 01:17:10 2006
@@ -61,6 +61,9 @@
     }
 
     public void processDocBare(JavaMethod javaMethod, Method method) {
+        if (model.getStyle() != SOAPBinding.Style.DOCUMENT) {
+            model.setStyle(SOAPBinding.Style.DOCUMENT);
+        }
         boolean isHolder = false;
         javaMethod.setSoapStyle(SOAPBinding.Style.DOCUMENT);
         javaMethod.setWrapperStyle(false);

Modified: incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DocWrapperMethodProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DocWrapperMethodProcessor.java?view=diff&rev=477118&r1=477117&r2=477118
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DocWrapperMethodProcessor.java (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DocWrapperMethodProcessor.java Mon Nov 20 01:17:10 2006
@@ -65,6 +65,9 @@
     }
 
     public void process(JavaMethod javaMethod, Method method) {
+        if (model.getStyle() != SOAPBinding.Style.DOCUMENT) {
+            model.setStyle(SOAPBinding.Style.DOCUMENT);
+        }        
         javaMethod.setSoapStyle(SOAPBinding.Style.DOCUMENT);
         javaMethod.setWrapperStyle(true);
         setMethodUse(javaMethod, method);

Modified: incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/RPCMethodProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/RPCMethodProcessor.java?view=diff&rev=477118&r1=477117&r2=477118
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/RPCMethodProcessor.java (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/RPCMethodProcessor.java Mon Nov 20 01:17:10 2006
@@ -56,6 +56,9 @@
     }
 
     public void process(JavaMethod javaMethod, Method method) {
+        if (model.getStyle() != SOAPBinding.Style.RPC) {
+            model.setStyle(SOAPBinding.Style.RPC);
+        }
         javaMethod.setSoapStyle(SOAPBinding.Style.RPC);
         javaMethod.setWrapperStyle(true);
         setMethodUse(javaMethod, method);

Added: incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/Hello.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/Hello.java?view=auto&rev=477118
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/Hello.java (added)
+++ incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/Hello.java Mon Nov 20 01:17:10 2006
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.tools.fortest.withannotation.rpc;
+ 
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.jws.soap.SOAPBinding.Use;
+
+@WebService(name = "Hello", targetNamespace = "http://cxf.com/")
+public interface Hello {
+ 
+    @SOAPBinding(parameterStyle = ParameterStyle.BARE, style = Style.RPC, use = Use.LITERAL) 
+    @WebMethod(operationName = "sayHi", exclude = false)
+    String sayHi();
+}

Propchange: incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/Hello.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/Hello.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java?view=diff&rev=477118&r1=477117&r2=477118
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java Mon Nov 20 01:17:10 2006
@@ -26,6 +26,8 @@
 import javax.wsdl.Definition;
 import javax.wsdl.Port;
 import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.wsdl.extensions.soap12.SOAP12Address;
 import javax.wsdl.extensions.soap12.SOAP12Binding;
 import javax.xml.namespace.QName;
@@ -172,6 +174,30 @@
         assertTrue(schemaFile.exists());
         File schemaFile2 = new File(output, "schema2.xsd");
         assertTrue(schemaFile2.exists());
+
+        Binding binding = def.getBinding(new QName(def.getTargetNamespace(), "GreeterRPCLitBinding"));
+        assertNotNull(binding);
+        Iterator it = binding.getExtensibilityElements().iterator();
+
+        while (it.hasNext()) {
+            Object obj = it.next();
+            assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
+            assertTrue(obj instanceof SOAPBinding);
+            SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
+            assertNotNull(soapBinding);
+            assertTrue("rpc".equalsIgnoreCase(soapBinding.getStyle()));
+            assertTrue(WSDLConstants.SOAP_HTTP_TRANSPORT.equalsIgnoreCase(soapBinding.getTransportURI()));
+        }
+        Port port = wsdlService.getPort("GreeterRPCLitPort");
+        assertNotNull(port);
+
+        it = port.getExtensibilityElements().iterator();
+        while (it.hasNext()) {
+            Object obj = it.next();
+            assertTrue(SOAPBindingUtil.isSOAPAddress(obj));
+            assertTrue(obj instanceof SOAPAddress);
+            assertEquals("http://localhost:9000/cxfService", ((SOAPAddress)obj).getLocationURI());
+        }
     }
 
     public void testSOAP12() throws Exception {
@@ -221,6 +247,37 @@
             Object obj = it.next();
             assertTrue(SOAPBindingUtil.isSOAPAddress(obj));
             assertTrue(obj instanceof SOAP12Address);
+            assertEquals("http://localhost:9000/cxfService", ((SOAP12Address)obj).getLocationURI());
+        }
+    }
+    
+    public void testRPCWithoutParentBindingAnnotation() throws Exception {
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/rpc_lit_service_no_anno.wsdl");
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.withannotation.rpc.Hello");
+        env.put(ToolConstants.CFG_SERVICENAME, serviceName);
+
+        j2wProcessor.setEnvironment(env);
+        j2wProcessor.process();
+        File wsdlFile = new File(output, "rpc_lit_service_no_anno.wsdl");
+        assertTrue(wsdlFile.exists());
+        assertTrue("WSDL file: " + wsdlFile.toString() + " is empty", wsdlFile.length() > 0);
+
+        Definition def = wsdlHelper.getDefinition(wsdlFile);
+        Service wsdlService = def.getService(new QName(def.getTargetNamespace(), serviceName));
+        assertNotNull("Generate WSDL Service Error", wsdlService);
+        Binding binding = def.getBinding(new QName(def.getTargetNamespace(), "HelloBinding"));
+        assertNotNull(binding);
+
+        Iterator it = binding.getExtensibilityElements().iterator();
+
+        while (it.hasNext()) {
+            Object obj = it.next();
+            assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
+            assertTrue(obj instanceof SOAPBinding);
+            SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
+            assertNotNull(soapBinding);
+            assertTrue("rpc".equalsIgnoreCase(soapBinding.getStyle()));
+            assertTrue(WSDLConstants.SOAP_HTTP_TRANSPORT.equalsIgnoreCase(soapBinding.getTransportURI()));
         }
     }