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/22 11:22:26 UTC

svn commit: r478111 - in /incubator/cxf/trunk/tools/java2wsdl/src: main/java/org/apache/cxf/tools/java2wsdl/processor/ main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ test/java/org/apache/cxf/tools/fortest/withannotation/doc/ test/java/org...

Author: mmao
Date: Wed Nov 22 02:22:25 2006
New Revision: 478111

URL: http://svn.apache.org/viewvc?view=rev&rev=478111
Log:
CXF-265
Java2WSDL NPE when the SEI is DOC-LIT Wrapped style and there is no RequestWrapper or ResponseWrapper annotation

Added:
    incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/
    incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/HelloWrapped.java   (with props)
Modified:
    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/DocWrapperMethodProcessor.java
    incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java

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=478111&r1=478110&r2=478111
==============================================================================
--- 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 Wed Nov 22 02:22:25 2006
@@ -30,8 +30,10 @@
 DOC_BARE_METHOD_CRITERIA1 = Method  {0} : must have at most one in or in/out non_header in Doc_bare method
 DOC_BARE_METHOD_CRITERIA2 = Method  {0} : has a return type of void it must have at most one in/out or out-header parameter in Doc_bare method
 DOC_BARE_METHOD_CRITERIA3 = Method  {0} : if it has a return type of void it must have at most one in/out or out-header parameter in Doc_bare method
-LOAD_CLASS_ERROR = Can Not Load class {0}
 FAIL_TO_BUILD_WSDLMODEL = Fail to build wsdl model
 GENERATE_TYPES_ERROR = Generate types error
+LOAD_REQUEST_WRAPPER_CLASS_ERROR = Can not load the request wrapper class {0},  please check the @RequestWrapper annotation and see if the class is in your classpath  
+LOAD_RESPONSE_WRAPPER_CLASS_ERROR = Can not load the response wrapper class {0}, please check the @ResponseWrapper annotation and see if the class is in your classpath
+
 
 

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=478111&r1=478110&r2=478111
==============================================================================
--- 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 Wed Nov 22 02:22:25 2006
@@ -43,6 +43,7 @@
 
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.common.model.JavaMethod;
 import org.apache.cxf.tools.common.model.JavaParameter;
@@ -77,7 +78,7 @@
         String reqClassName = "";
         String reqName = method.getName();
         String reqNS = model.getTargetNameSpace();
-        if (!reqWrapper.className().equals("")) {
+        if (reqWrapper != null && !StringUtils.isEmpty(reqWrapper.className())) {
             reqClassName = reqWrapper.className().length() > 0 ? reqWrapper.className() : reqClassName;
             reqName = reqWrapper.localName().length() > 0 ? reqWrapper.localName() : reqName;
             reqNS = reqWrapper.targetNamespace().length() > 0 ? reqWrapper.targetNamespace() : reqNS;
@@ -89,7 +90,7 @@
         try {
             reqClass = AnnotationUtil.loadClass(reqClassName, this.getClass().getClassLoader());
         } catch (Exception e) {
-            Message msg = new Message("LOAD_CLASS_ERROR", LOG, reqClassName);
+            Message msg = new Message("LOAD_REQUEST_WRAPPER_CLASS_ERROR", LOG, reqClassName);
             throw new ToolException(msg, e);
         }
         QName reqQN = new QName(reqNS, reqName);
@@ -106,7 +107,7 @@
             // rule 3.5 suffix -"Response"
             String resName = method.getName() + "Response";
             String resNS = model.getTargetNameSpace();
-            if (!resWrapper.className().equals("")) {
+            if (resWrapper != null && !StringUtils.isEmpty(resWrapper.className())) {
                 resClassName = resWrapper.className();
                 resName = resWrapper.localName().length() > 0 ? resWrapper.localName() : resName;
                 resNS = resWrapper.targetNamespace().length() > 0 ? resWrapper.targetNamespace() : resNS;
@@ -121,7 +122,7 @@
                 resClass = AnnotationUtil
                     .loadClass(resClassName, method.getDeclaringClass().getClassLoader());
             } catch (Exception e) {
-                Message msg = new Message("LOAD_CLASS_ERROR", LOG, resClassName);
+                Message msg = new Message("LOAD_RESPONSE_WRAPPER_CLASS_ERROR", LOG, resClassName);
                 throw new ToolException(msg, e);
             }
             typeRef = new TypeReference(resQN, resClass, new Annotation[0]);

Added: incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/HelloWrapped.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/HelloWrapped.java?view=auto&rev=478111
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/HelloWrapped.java (added)
+++ incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/HelloWrapped.java Wed Nov 22 02:22:25 2006
@@ -0,0 +1,31 @@
+/**
+ * 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.doc;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL)
+@WebService(name = "Hello", targetNamespace = "http://cxf.com/")
+public interface HelloWrapped {
+    @WebMethod(operationName = "sayHi", exclude = false)
+    String sayHi();
+}

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

Propchange: incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/HelloWrapped.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=478111&r1=478110&r2=478111
==============================================================================
--- 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 Wed Nov 22 02:22:25 2006
@@ -34,6 +34,7 @@
 
 import org.apache.cxf.helpers.WSDLHelper;
 import org.apache.cxf.tools.common.ToolConstants;
+import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.common.WSDLConstants;
 import org.apache.cxf.tools.common.extensions.soap.SoapBinding;
 import org.apache.cxf.tools.util.SOAPBindingUtil;
@@ -278,6 +279,22 @@
             assertNotNull(soapBinding);
             assertTrue("rpc".equalsIgnoreCase(soapBinding.getStyle()));
             assertTrue(WSDLConstants.SOAP_HTTP_TRANSPORT.equalsIgnoreCase(soapBinding.getTransportURI()));
+        }
+    }
+    
+    public void testDocWrappedWithoutWrapperClass() {
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/doc_lit_wrapped_no_anno.wsdl");
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.withannotation.doc.HelloWrapped");
+        env.put(ToolConstants.CFG_SERVICENAME, serviceName);
+        j2wProcessor.setEnvironment(env);
+        String expected = "Can not load the request wrapper class " 
+            + "org.apache.cxf.tools.fortest.withannotation.doc.jaxws.SayHi";
+        try {        
+            j2wProcessor.process();
+        } catch (ToolException e) {           
+            assertTrue(e.getMessage().contains(expected));
+        } catch (Exception e) {
+            fail("Should not happen other exception " + e.getMessage());
         }
     }