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/23 06:54:37 UTC
svn commit: r478477 - in /incubator/cxf/trunk:
rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/
rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/
testutils/src/main/java/org/apache/hello_world_soap_http/
tools/java2wsdl/src/main/java/o...
Author: mmao
Date: Wed Nov 22 21:54:35 2006
New Revision: 478477
URL: http://svn.apache.org/viewvc?view=rev&rev=478477
Log:
CXF-263
* If the public method do not have WebMethod annotation but the declaring class has the WebService annotation, the method is a valid method.
Fixed this in the jaxws runtime
Defined ing JAX-WS spec, Section 3.3
* Tools and run time should both report error, if the SOAPBinding annotation is placed on method with the RPC style.
Defined in the JSR-181 Section 4.7.1
Added:
incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/HelloWrongAnnotation.java (with props)
incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/HelloWrongAnnotation.java (with props)
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.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/ClassProcessor.java
incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/Hello.java
incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?view=diff&rev=478477&r1=478476&r2=478477
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java Wed Nov 22 21:54:35 2006
@@ -42,6 +42,7 @@
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.i18n.BundleUtils;
import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.resource.URIResolver;
import org.apache.cxf.service.factory.AbstractServiceConfiguration;
import org.apache.cxf.service.factory.DefaultServiceConfiguration;
@@ -150,11 +151,15 @@
return Boolean.TRUE;
}
} else {
- return method.getDeclaringClass().isInterface();
+ return hasWebServiceAnnotation(method);
}
}
return Boolean.FALSE;
}
+
+ private boolean hasWebServiceAnnotation(Method method) {
+ return method.getDeclaringClass().getAnnotation(WebService.class) != null;
+ }
Method getDeclaredMethod(Method method) {
Class endpointClass = implInfo.getEndpointClass();
@@ -404,7 +409,13 @@
SOAPBinding ann = m.getAnnotation(SOAPBinding.class);
if (ann != null) {
- return !(ann.parameterStyle().equals(ParameterStyle.BARE) || ann.style().equals(Style.RPC));
+ if (ann.style().equals(Style.RPC)) {
+ throw new Fault(new RuntimeException("Method ["
+ + m.getName()
+ + "] processing error: "
+ + "SOAPBinding can not on method with RPC style"));
+ }
+ return !(ann.parameterStyle().equals(ParameterStyle.BARE));
}
return isWrapped();
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java?view=diff&rev=478477&r1=478476&r2=478477
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java Wed Nov 22 21:54:35 2006
@@ -35,6 +35,7 @@
import org.apache.cxf.transport.MessageObserver;
import org.apache.hello_world_soap_http.GreeterImpl;
import org.apache.hello_world_soap_http.HelloImpl;
+import org.apache.hello_world_soap_http.HelloWrongAnnotation;
public class EndpointImplTest extends AbstractJaxWsTest {
@@ -103,6 +104,21 @@
} catch (IllegalArgumentException ex) {
assertTrue(ex.getCause() instanceof BusException);
assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ }
+ }
+
+ public void testSOAPBindingOnMethodWithRPC() {
+ HelloWrongAnnotation hello = new HelloWrongAnnotation();
+ JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
+ serviceFactory.setBus(getBus());
+ serviceFactory.setInvoker(new BeanInvoker(hello));
+ serviceFactory.setServiceClass(HelloWrongAnnotation.class);
+
+ try {
+ new EndpointImpl(getBus(), hello, serviceFactory);
+ } catch (Exception e) {
+ String expeced = "Method [sayHi] processing error: SOAPBinding can not on method with RPC style";
+ assertEquals(expeced, e.getMessage());
}
}
Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/HelloWrongAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/HelloWrongAnnotation.java?view=auto&rev=478477
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/HelloWrongAnnotation.java (added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/HelloWrongAnnotation.java Wed Nov 22 21:54:35 2006
@@ -0,0 +1,16 @@
+package org.apache.hello_world_soap_http;
+
+import javax.jws.soap.SOAPBinding;
+
+@javax.jws.WebService(name = "HelloWrongAnnotation",
+ serviceName = "HelloService",
+ portName = "HelloPort",
+ targetNamespace = "http://apache.org/hello_world_soap_http"
+ )
+
+public class HelloWrongAnnotation {
+ @SOAPBinding(style = SOAPBinding.Style.RPC, use = SOAPBinding.Use.LITERAL)
+ public String sayHi() {
+ return "Hello CXF";
+ }
+}
Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/HelloWrongAnnotation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/HelloWrongAnnotation.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
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=478477&r1=478476&r2=478477
==============================================================================
--- 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 21:54:35 2006
@@ -34,6 +34,6 @@
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
-
+SOAPBinding_RPC_ON_METHOD = Method [{0}] processing error : SOAPBinding annotation can not be placed on method with RPC style
Modified: incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ClassProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ClassProcessor.java?view=diff&rev=478477&r1=478476&r2=478477
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ClassProcessor.java (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ClassProcessor.java Wed Nov 22 21:54:35 2006
@@ -141,7 +141,8 @@
int result = WSDLConstants.ERORR_STYLE_USE;
if (binding != null) {
if (binding.style() == SOAPBinding.Style.RPC) {
- result = WSDLConstants.RPC_WRAPPED;
+ Message message = new Message("SOAPBinding_RPC_ON_METHOD", LOG, method.getName());
+ throw new ToolException(message);
}
if (binding.style() == SOAPBinding.Style.DOCUMENT
&& binding.parameterStyle() == SOAPBinding.ParameterStyle.WRAPPED) {
Modified: 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=diff&rev=478477&r1=478476&r2=478477
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/Hello.java (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/Hello.java Wed Nov 22 21:54:35 2006
@@ -22,14 +22,13 @@
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/")
+@SOAPBinding(style = Style.RPC, use = Use.LITERAL)
public interface Hello {
-
- @SOAPBinding(parameterStyle = ParameterStyle.BARE, style = Style.RPC, use = Use.LITERAL)
+
@WebMethod(operationName = "sayHi", exclude = false)
String sayHi();
}
Added: incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/HelloWrongAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/HelloWrongAnnotation.java?view=auto&rev=478477
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/HelloWrongAnnotation.java (added)
+++ incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/HelloWrongAnnotation.java Wed Nov 22 21:54:35 2006
@@ -0,0 +1,34 @@
+/**
+ * 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.Style;
+import javax.jws.soap.SOAPBinding.Use;
+
+@WebService(name = "HelloWrongAnnotation", targetNamespace = "http://cxf.com/")
+public interface HelloWrongAnnotation {
+
+ @SOAPBinding(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/HelloWrongAnnotation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/fortest/withannotation/rpc/HelloWrongAnnotation.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=478477&r1=478476&r2=478477
==============================================================================
--- 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 21:54:35 2006
@@ -287,11 +287,28 @@
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) {
+ } catch (ToolException e) {
+ String expected = "Can not load the request wrapper class "
+ + "org.apache.cxf.tools.fortest.withannotation.doc.jaxws.SayHi";
+ assertTrue(e.getMessage().contains(expected));
+ } catch (Exception e) {
+ fail("Should not happen other exception " + e.getMessage());
+ }
+ }
+
+ public void testSOAPBindingRPCOnMethod() {
+ env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/rpc_on_method.wsdl");
+ env.put(ToolConstants.CFG_CLASSNAME,
+ "org.apache.cxf.tools.fortest.withannotation.rpc.HelloWrongAnnotation");
+ env.put(ToolConstants.CFG_SERVICENAME, serviceName);
+ j2wProcessor.setEnvironment(env);
+ try {
+ j2wProcessor.process();
+ } catch (ToolException e) {
+ String expected = "Method [sayHi] processing error : SOAPBinding annotation "
+ + "can not be placed on method with RPC style";
assertTrue(e.getMessage().contains(expected));
} catch (Exception e) {
fail("Should not happen other exception " + e.getMessage());