Author: mmao
Date: Tue Dec 11 01:37:50 2007
New Revision: 603187
URL: http://svn.apache.org/viewvc?rev=603187&view=rev
Log:
CXF-1287
* WS-Addressing could be disabled by explicitly disabling the
AddressingFeature
even if the wsdl contains UsingAddressing
* Remove a TODO, since now the client can enable the WS-A by reading the
UsingAddressing from the wsdl
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/AddNumberImpl.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/Server.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/WSADisableTest.java
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?rev=603187&r1=603186&r2=603187&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
Tue Dec 11 01:37:50 2007
@@ -91,7 +91,6 @@
this.implInfo = implementorInfo;
this.wsFeatures = wf;
this.features = af;
- resolveFeatures();
createJaxwsBinding();
List<Interceptor> in = super.getInInterceptors();
@@ -150,6 +149,7 @@
}
extractWsdlExtensibilities(ei);
}
+ resolveFeatures();
}
private void extractWsdlExtensibilities(EndpointInfo endpoint) {
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/AddNumberImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/AddNumberImpl.java?rev=603187&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/AddNumberImpl.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/AddNumberImpl.java
Tue Dec 11 01:37:50 2007
@@ -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.systest.ws.addr_disable;
+
+import javax.jws.WebService;
+import javax.xml.ws.soap.Addressing;
+
+import org.apache.cxf.systest.ws.addr_feature.AddNumbersFault;
+import org.apache.cxf.systest.ws.addr_feature.AddNumbersFault_Exception;
+import org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType;
+
+// Jax-WS 2.1 WS-Addressing FromWsdl
+
[EMAIL PROTECTED](enabled = false)
[EMAIL PROTECTED](serviceName = "AddNumbersService",
+ targetNamespace = "http://apache.org/cxf/systest/ws/addr_feature/")
+public class AddNumberImpl implements AddNumbersPortType {
+ public int addNumbers(int number1, int number2) throws
AddNumbersFault_Exception {
+ return execute(number1, number2);
+ }
+
+ public int addNumbers2(int number1, int number2) {
+ return number1 + number2;
+ }
+
+ public int addNumbers3(int number1, int number2) throws
AddNumbersFault_Exception {
+ return execute(number1, number2);
+ }
+
+ int execute(int number1, int number2) throws AddNumbersFault_Exception {
+ if (number1 < 0 || number2 < 0) {
+ AddNumbersFault fb = new AddNumbersFault();
+ fb.setDetail("Negative numbers cant be added!");
+ fb.setMessage("Numbers: " + number1 + ", " + number2);
+
+ throw new AddNumbersFault_Exception(fb.getMessage(), fb);
+ }
+
+ return number1 + number2;
+ }
+}
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/Server.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/Server.java?rev=603187&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/Server.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/Server.java
Tue Dec 11 01:37:50 2007
@@ -0,0 +1,60 @@
+/**
+ * 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.systest.ws.addr_disable;
+
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server extends AbstractBusTestServerBase {
+
+ protected void run() {
+ Object implementor = new AddNumberImpl();
+ String address = "http://localhost:9095/jaxws/add";
+
+ EndpointImpl ep = new EndpointImpl(BusFactory.getThreadDefaultBus(),
+ implementor,
+ null,
+ getWsdl());
+ ep.publish(address);
+ }
+
+ private String getWsdl() {
+ try {
+ java.net.URL wsdl =
getClass().getResource("/wsdl/add_numbers.wsdl");
+ return wsdl.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ 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!");
+ }
+ }
+}
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/WSADisableTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/WSADisableTest.java?rev=603187&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/WSADisableTest.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_disable/WSADisableTest.java
Tue Dec 11 01:37:50 2007
@@ -0,0 +1,118 @@
+/**
+ * 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.systest.ws.addr_disable;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.soap.AddressingFeature;
+
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType;
+import org.apache.cxf.systest.ws.addr_feature.AddNumbersService;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WSADisableTest extends AbstractBusClientServerTestBase {
+
+ private final QName serviceName = new
QName("http://apache.org/cxf/systest/ws/addr_feature/",
+ "AddNumbersService");
+
+ @Before
+ public void setUp() throws Exception {
+ createBus();
+ }
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("server did not launch correctly",
launchServer(Server.class));
+ }
+
+ private ByteArrayOutputStream setupInLogging() {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ PrintWriter writer = new PrintWriter(bos, true);
+ LoggingInInterceptor in = new LoggingInInterceptor(writer);
+ this.bus.getInInterceptors().add(in);
+ return bos;
+ }
+
+ private ByteArrayOutputStream setupOutLogging() {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ PrintWriter writer = new PrintWriter(bos, true);
+
+ LoggingOutInterceptor out = new LoggingOutInterceptor(writer);
+ this.bus.getOutInterceptors().add(out);
+
+ return bos;
+ }
+
+ @Test
+ public void testDisableServerSide() throws Exception {
+ ByteArrayOutputStream input = setupInLogging();
+ ByteArrayOutputStream output = setupOutLogging();
+
+ AddNumbersPortType port = getService().getAddNumbersPort();
+
+
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+
"http://localhost:9095/jaxws/add");
+
+ assertEquals(3, port.addNumbers(1, 2));
+
+ String base =
"http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/";
+ String expectedOut = base + "addNumbersRequest</Action>";
+ String expectedIn = "http://www.w3.org/2005/08/addressing";
+
+ assertTrue(output.toString().indexOf(expectedOut) != -1);
+ assertTrue(input.toString().indexOf(expectedIn) == -1);
+ }
+
+ @Test
+ public void testDisableAll() throws Exception {
+ ByteArrayOutputStream input = setupInLogging();
+ ByteArrayOutputStream output = setupOutLogging();
+
+ AddNumbersPortType port = getService().getAddNumbersPort(new
AddressingFeature(false));
+
+
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+
"http://localhost:9095/jaxws/add");
+
+ assertEquals(3, port.addNumbers(1, 2));
+
+ String expectedOut = "http://www.w3.org/2005/08/addressing";
+ String expectedIn = "http://www.w3.org/2005/08/addressing";
+
+ assertTrue(output.toString().indexOf(expectedOut) == -1);
+ assertTrue(input.toString().indexOf(expectedIn) == -1);
+ }
+
+ private AddNumbersService getService() {
+ URL wsdl = getClass().getResource("/wsdl/add_numbers.wsdl");
+ assertNotNull("WSDL is null", wsdl);
+
+ AddNumbersService service = new AddNumbersService(wsdl, serviceName);
+ assertNotNull("Service is null ", service);
+ return service;
+ }
+}
\ No newline at end of file
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java?rev=603187&r1=603186&r2=603187&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
Tue Dec 11 01:37:50 2007
@@ -147,7 +147,6 @@
AddNumberImplService service = new AddNumberImplService(wsdl);
assertNotNull("Service is null ", service);
- // TODO, this is wrong, the addressing could be enabled by reading the
wsdl extensions
- return service.getAddNumberImplPort(new AddressingFeature());
+ return service.getAddNumberImplPort();
}
}