Author: ema
Date: Thu Sep 29 10:05:45 2011
New Revision: 1177248
URL: http://svn.apache.org/viewvc?rev=1177248&view=rev
Log:
[CXF-2006]:Check UnknownExtensibilityElement when RespectBindingFeature is
enalbed
Added:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/RespectBindingFeatureClientServerTest.java
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/Server.java
cxf/trunk/systests/uncategorized/src/test/resources/wsdl_systest/cxf2006.wsdl
Modified:
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
Modified:
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?rev=1177248&r1=1177247&r2=1177248&view=diff
==============================================================================
---
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
(original)
+++
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
Thu Sep 29 10:05:45 2011
@@ -23,6 +23,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.logging.Logger;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.ExtensionRegistry;
@@ -30,7 +31,9 @@ import javax.wsdl.extensions.UnknownExte
import javax.xml.namespace.QName;
import javax.xml.transform.dom.DOMSource;
import javax.xml.ws.Binding;
+import javax.xml.ws.RespectBindingFeature;
import javax.xml.ws.Service.Mode;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.soap.Addressing;
import javax.xml.ws.soap.AddressingFeature;
@@ -46,6 +49,7 @@ import org.apache.cxf.binding.soap.saaj.
import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
import org.apache.cxf.binding.xml.XMLBinding;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.endpoint.EndpointException;
import org.apache.cxf.endpoint.EndpointImpl;
import org.apache.cxf.feature.AbstractFeature;
@@ -95,6 +99,8 @@ import org.apache.neethi.Constants;
*
*/
public class JaxWsEndpointImpl extends EndpointImpl {
+
+ private static final Logger LOG =
LogUtils.getL7dLogger(JaxWsEndpointImpl.class);
private Binding jaxwsBinding;
private JaxWsImplementorInfo implInfo;
@@ -109,7 +115,7 @@ public class JaxWsEndpointImpl extends E
private SOAPHandlerFaultOutInterceptor soapFaultOutInterceptor;
private LogicalHandlerFaultInInterceptor logicalFaultInInterceptor;
private SOAPHandlerFaultInInterceptor soapFaultInInterceptor;
-
+
public JaxWsEndpointImpl(Bus bus, Service s, EndpointInfo ei) throws
EndpointException {
this(bus, s, ei, null, null, null, true);
}
@@ -198,6 +204,7 @@ public class JaxWsEndpointImpl extends E
= endpoint.getBinding().getExtensors(ExtensibilityElement.class);
List<ExtensibilityElement> portExtensors
= endpoint.getExtensors(ExtensibilityElement.class);
+ checkRespectBindingFeature(bindingExtensors);
if (hasUsingAddressing(bindingExtensors) ||
hasUsingAddressing(portExtensors)) {
WSAddressingFeature feature = new WSAddressingFeature();
if (addressingRequired(bindingExtensors)
@@ -209,6 +216,27 @@ public class JaxWsEndpointImpl extends E
extractWsdlEprs(endpoint);
}
+ private void checkRespectBindingFeature(List<ExtensibilityElement>
bindingExtensors) {
+ if (bindingExtensors != null) {
+ Iterator<ExtensibilityElement> extensionElements =
bindingExtensors.iterator();
+ while (extensionElements.hasNext()) {
+ ExtensibilityElement ext =
(ExtensibilityElement)extensionElements.next();
+ if (ext instanceof UnknownExtensibilityElement &&
Boolean.TRUE.equals(ext.getRequired())) {
+ for (WebServiceFeature feature : this.wsFeatures) {
+ if (feature instanceof RespectBindingFeature &&
feature.isEnabled()) {
+
+ org.apache.cxf.common.i18n.Message message =
+ new
org.apache.cxf.common.i18n.Message("UNKONW_REQUIRED_WSDL_BINDING", LOG);
+ LOG.severe(message.toString());
+ throw new WebServiceException(message.toString());
+ }
+ }
+ }
+ }
+ }
+
+ }
+
private void extractWsdlEprs(EndpointInfo endpoint) {
//parse the EPR in wsdl
List<ExtensibilityElement> portExtensors =
endpoint.getExtensors(ExtensibilityElement.class);
Modified:
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties?rev=1177248&r1=1177247&r2=1177248&view=diff
==============================================================================
---
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
(original)
+++
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
Thu Sep 29 10:05:45 2011
@@ -33,4 +33,8 @@ SERVICECLASS_MUST_BE_SET = serviceClass
XMLSEEALSO_NULL_CLASS = A class listed in the XmlSeeAlso annotation of the
service class %s cannot be found on the classpath. Index: %d of XmlSeeAlso
class list.
WEBMETHOD_EXCLUDE_NOT_ALLOWED = The @javax.jws.WebMethod(exclude=true) cannot
be used on a service endpoint interface. Method: {0}
WEBSERVICE_ANNOTATIONS_IS_LOADED_BY_OTHER_CLASSLOADER = The {0} annotation was
already loaded by another classloader. Please check if there are multiple
versions of the web service annotation jar in your classpath.
+UNKONW_REQUIRED_WSDL_BINDING = RespectBindingFeature is enabled and there is
wsdl:extensions that have the required=true attribute
+attribute
+
+
Added:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/RespectBindingFeatureClientServerTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/RespectBindingFeatureClientServerTest.java?rev=1177248&view=auto
==============================================================================
---
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/RespectBindingFeatureClientServerTest.java
(added)
+++
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/RespectBindingFeatureClientServerTest.java
Thu Sep 29 10:05:45 2011
@@ -0,0 +1,64 @@
+/**
+ * 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.cxf2006;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.RespectBindingFeature;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.hello_world_rpclit.GreeterRPCLit;
+import org.apache.hello_world_rpclit.SOAPServiceRPCLit;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class RespectBindingFeatureClientServerTest extends
AbstractBusClientServerTestBase {
+ public static final String PORT = Server.PORT;
+ private final QName portName = new
QName("http://apache.org/hello_world_rpclit", "SoapPortRPCLit");
+ private SOAPServiceRPCLit service = new SOAPServiceRPCLit();
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("server did not launch correctly",
launchServer(Server.class));
+ }
+
+ @Test
+ public void testRespectBindingFeature() throws Exception {
+ try {
+ GreeterRPCLit greeter = service.getPort(portName,
GreeterRPCLit.class,
+ new
RespectBindingFeature(true));
+ updateAddressPort(greeter, PORT);
+ greeter.greetMe("hello");
+ fail("WebServiceException is expected");
+ } catch (Exception ex) {
+ assertTrue("WebServiceException is expected", ex instanceof
javax.xml.ws.WebServiceException);
+ assertTrue("RespectBindingFeature message is expceted",
+ ex.getMessage().indexOf("extensions that have the
required=true attribute") > -1);
+ }
+ }
+
+ @Test
+ public void testRespectBindingFeatureFalse() throws Exception {
+
+ GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class,
+ new
RespectBindingFeature(false));
+ updateAddressPort(greeter, PORT);
+ assertEquals("Bonjour" , greeter.sayHi());
+ }
+
+}
Added:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/Server.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/Server.java?rev=1177248&view=auto
==============================================================================
---
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/Server.java
(added)
+++
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/Server.java
Thu Sep 29 10:05:45 2011
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf2006;
+
+import java.net.URL;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.hello_world_soap_http.RPCLitGreeterImpl;
+
+public class Server extends AbstractBusTestServerBase {
+ public static final String PORT = allocatePort(Server.class);
+ protected void run() {
+ String address;
+ Object implementor = new RPCLitGreeterImpl();
+ address = "http://localhost:" + PORT + "/SOAPServiceRPCLit/SoapPort";
+ Endpoint ep = Endpoint.create(implementor);
+
+ URL wsdl = getClass().getResource("/wsdl_systest/cxf2006.wsdl");
+ ((EndpointImpl)ep).setWsdlLocation(wsdl.toString());
+ ((EndpointImpl)ep).getInInterceptors().add(new LoggingInInterceptor());
+ ((EndpointImpl)ep).getOutInterceptors().add(new
LoggingOutInterceptor());
+ ep.publish(address);
+ }
+
+ public static void main(String[] args) {
+ try {
+ Server s = new Server();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+}
\ No newline at end of file
Added:
cxf/trunk/systests/uncategorized/src/test/resources/wsdl_systest/cxf2006.wsdl
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/resources/wsdl_systest/cxf2006.wsdl?rev=1177248&view=auto
==============================================================================
---
cxf/trunk/systests/uncategorized/src/test/resources/wsdl_systest/cxf2006.wsdl
(added)
+++
cxf/trunk/systests/uncategorized/src/test/resources/wsdl_systest/cxf2006.wsdl
Thu Sep 29 10:05:45 2011
@@ -0,0 +1,142 @@
+<?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. -->
+<wsdl:definitions name="HelloWorld"
+ targetNamespace="http://apache.org/hello_world_rpclit"
xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://apache.org/hello_world_rpclit"
+ xmlns:x1="http://apache.org/hello_world_rpclit/types"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:foo='http://foo.org/foo'>
+ <wsdl:types>
+ <schema
targetNamespace="http://apache.org/hello_world_rpclit/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
+ <complexType name="myComplexStruct">
+ <sequence>
+ <element name="elem1" type="xsd:string"
/>
+ <element name="elem2" type="xsd:string"
/>
+ <element name="elem3" type="xsd:int" />
+ </sequence>
+ </complexType>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="sayHiRequest" />
+
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part type="xsd:string" name="out" />
+ </wsdl:message>
+
+ <wsdl:message name="greetMeRequest">
+ <wsdl:part type="xsd:string" name="in" />
+ </wsdl:message>
+
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part type="xsd:string" name="out" />
+ </wsdl:message>
+
+ <wsdl:message name="greetUsRequest">
+ <wsdl:part type="xsd:string" name="you" />
+ <wsdl:part type="xsd:string" name="me" />
+ </wsdl:message>
+
+ <wsdl:message name="greetUsResponse">
+ <wsdl:part type="xsd:string" name="out" />
+ </wsdl:message>
+
+ <wsdl:message name="sendReceiveDataRequest">
+ <wsdl:part type="x1:myComplexStruct" name="in" />
+ </wsdl:message>
+
+ <wsdl:message name="sendReceiveDataResponse">
+ <wsdl:part type="x1:myComplexStruct" name="out" />
+ </wsdl:message>
+
+ <wsdl:portType name="GreeterRPCLit">
+ <wsdl:operation name="sayHi">
+ <wsdl:input message="tns:sayHiRequest"
name="sayHiRequest" />
+ <wsdl:output message="tns:sayHiResponse"
name="sayHiResponse" />
+ </wsdl:operation>
+ <wsdl:operation name="greetMe">
+ <wsdl:input message="tns:greetMeRequest"
name="greetMeRequest" />
+ <wsdl:output message="tns:greetMeResponse"
name="greetMeResponse" />
+ </wsdl:operation>
+ <wsdl:operation name="sendReceiveData">
+ <wsdl:input message="tns:sendReceiveDataRequest"
name="SendReceiveDataRequest" />
+ <wsdl:output message="tns:sendReceiveDataResponse"
name="SendReceiveDataResponse" />
+ </wsdl:operation>
+ <wsdl:operation name="greetUs">
+ <wsdl:input message="tns:greetUsRequest"
name="greetUsRequest" />
+ <wsdl:output message="tns:greetUsResponse"
name="greetUsResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="Greeter_SOAPBinding_RPCLit"
type="tns:GreeterRPCLit">
+
+ <soap:binding style="rpc"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <foo:bar wsdl:required="true" />
+
+ <wsdl:operation name="sayHi">
+ <soap:operation soapAction="" style="rpc" />
+ <wsdl:input>
+ <soap:body
namespace="http://apache.org/hello_world_rpclit"
+ use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body
namespace="http://apache.org/hello_world_rpclit"
+ use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <soap:operation soapAction="" style="rpc" />
+ <wsdl:input>
+ <soap:body
namespace="http://apache.org/hello_world_rpclit"
+ use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body
namespace="http://apache.org/hello_world_rpclit"
+ use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetUs">
+ <soap:operation soapAction="" style="rpc" />
+ <wsdl:input>
+ <soap:body
namespace="http://apache.org/hello_world_rpclit"
+ use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body
namespace="http://apache.org/hello_world_rpclit"
+ use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="sendReceiveData">
+ <soap:operation soapAction="" style="rpc" />
+ <wsdl:input>
+ <soap:body
namespace="http://apache.org/hello_world_rpclit"
+ use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body
namespace="http://apache.org/hello_world_rpclit"
+ use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="SOAPServiceRPCLit">
+ <wsdl:port binding="tns:Greeter_SOAPBinding_RPCLit"
name="SoapPortRPCLit">
+ <soap:address
location="http://localhost:9002/SOAPServiceRPCLit/SoapPort" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
\ No newline at end of file