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 2007/11/27 10:40:05 UTC
svn commit: r598570 - in /incubator/cxf/trunk:
rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ systests/
systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/
systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/
systests/src/...
Author: mmao
Date: Tue Nov 27 01:40:04 2007
New Revision: 598570
URL: http://svn.apache.org/viewvc?rev=598570&view=rev
Log:
CXF-1191
WS-A runtime support Action header element in two cases:
* no input/output name in the operation
* has input/output name in the operation
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/AddNumberImpl.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/Server.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/WSAFromWSDLTest.java
incubator/cxf/trunk/systests/src/test/resources/wsdl/pizza_service-options
Modified:
incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
incubator/cxf/trunk/systests/ (props changed)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/AddNumberImpl.java
incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers.wsdl
Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?rev=598570&r1=598569&r2=598570&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java (original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java Tue Nov 27 01:40:04 2007
@@ -19,7 +19,6 @@
package org.apache.cxf.ws.addressing;
-
import java.text.MessageFormat;
import java.util.Collection;
import java.util.Iterator;
@@ -29,7 +28,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
-
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
@@ -41,6 +39,7 @@
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.OperationInfo;
import org.apache.cxf.transport.Conduit;
import org.apache.cxf.transport.Destination;
import org.apache.cxf.ws.addressing.policy.MetadataConstants;
@@ -379,9 +378,46 @@
if (ContextUtils.hasEmptyAction(maps)) {
maps.setAction(ContextUtils.getAction(message));
}
+
+ if (ContextUtils.isOutbound(message)) {
+ maps.setAction(ContextUtils.getAttributedURI(getActionUri(message)));
+ }
return maps;
}
+ private String getActionUri(Message message) {
+ OperationInfo op = message.getExchange().get(OperationInfo.class);
+ String interfaceName = op.getInterface().getName().getLocalPart();
+
+ String actionUri = null;
+ String opNamespace = addPath(op.getName().getNamespaceURI(), interfaceName);
+
+ if (ContextUtils.isRequestor(message)) {
+ if (null == op.getInputName()) {
+ actionUri = addPath(opNamespace, op.getName().getLocalPart() + "Request");
+ } else {
+ actionUri = addPath(opNamespace, op.getInputName());
+ }
+ } else {
+ if (null == op.getOutputName()) {
+ actionUri = addPath(opNamespace, op.getOutput().getName().getLocalPart());
+ } else {
+ actionUri = addPath(opNamespace, op.getOutputName());
+ }
+ }
+ return actionUri;
+ }
+
+ private String addPath(String uri, String path) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(uri);
+ if (!uri.endsWith("/") && !path.startsWith("/")) {
+ buffer.append("/");
+ }
+ buffer.append(path);
+ return buffer.toString();
+ }
+
/**
* Add MAPs which are specific to the requestor or responder role.
*
Propchange: incubator/cxf/trunk/systests/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Nov 27 01:40:04 2007
@@ -6,4 +6,6 @@
.classpath
.project
.wtpmodules
-
+build
+lib
+prj.el
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/AddNumberImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/AddNumberImpl.java?rev=598570&r1=598569&r2=598570&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/AddNumberImpl.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/AddNumberImpl.java Tue Nov 27 01:40:04 2007
@@ -30,4 +30,8 @@
public int addNumbers(int number1, int number2) {
return number1 + number2;
}
+
+ public int addNumbers2(int number1, int number2) {
+ return number1 + number2;
+ }
}
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/AddNumberImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/AddNumberImpl.java?rev=598570&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/AddNumberImpl.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/AddNumberImpl.java Tue Nov 27 01:40:04 2007
@@ -0,0 +1,39 @@
+/**
+ * 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_fromwsdl;
+
+import javax.jws.WebService;
+import javax.xml.ws.soap.Addressing;
+import org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType;
+
+// Jax-WS 2.1 WS-Addressing FromWsdl
+
+@Addressing
+@WebService(serviceName = "AddNumbersService",
+ targetNamespace = "http://apache.org/cxf/systest/ws/addr_feature/")
+public class AddNumberImpl implements AddNumbersPortType {
+ public int addNumbers(int number1, int number2) {
+ return number1 + number2;
+ }
+
+ public int addNumbers2(int number1, int number2) {
+ return number1 + number2;
+ }
+}
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/Server.java?rev=598570&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/Server.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/Server.java Tue Nov 27 01:40:04 2007
@@ -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.systest.ws.addr_fromwsdl;
+
+
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.ws.addressing.WSAddressingFeature;
+
+public class Server extends AbstractBusTestServerBase {
+
+ protected void run() {
+ Object implementor = new AddNumberImpl();
+ String address = "http://localhost:9091/jaxws/add";
+
+ EndpointImpl ep = new EndpointImpl(BusFactory.getThreadDefaultBus(),
+ implementor,
+ null,
+ getWsdl());
+
+ ep.getFeatures().add(new WSAddressingFeature());
+ 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_fromwsdl/WSAFromWSDLTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/WSAFromWSDLTest.java?rev=598570&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/WSAFromWSDLTest.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/WSAFromWSDLTest.java Tue Nov 27 01:40:04 2007
@@ -0,0 +1,114 @@
+/**
+ * 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_fromwsdl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.net.URL;
+import javax.xml.namespace.QName;
+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 WSAFromWSDLTest extends AbstractBusClientServerTestBase {
+
+ private static final String BASE_URI = "http://apache.org/cxf/systest/ws/addr_feature/"
+ + "AddNumbersPortType/";
+
+ 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 testAddNumbers() throws Exception {
+ ByteArrayOutputStream input = setupInLogging();
+ ByteArrayOutputStream output = setupOutLogging();
+
+ AddNumbersPortType port = getPort();
+
+ assertEquals(3, port.addNumbers(1, 2));
+
+ String expectedOut = BASE_URI + "addNumbersRequest";
+ String expectedIn = BASE_URI + "addNumbersResponse";
+
+ assertTrue(output.toString().indexOf(expectedOut) != -1);
+ assertTrue(input.toString().indexOf(expectedIn) != -1);
+ }
+
+ @Test
+ public void testAddNumbers2() throws Exception {
+ ByteArrayOutputStream input = setupInLogging();
+ ByteArrayOutputStream output = setupOutLogging();
+
+ AddNumbersPortType port = getPort();
+
+ assertEquals(3, port.addNumbers2(1, 2));
+
+ String expectedOut = BASE_URI + "add2In";
+ String expectedIn = BASE_URI + "add2Out";
+
+ assertTrue(output.toString().indexOf(expectedOut) != -1);
+ assertTrue(input.toString().indexOf(expectedIn) != -1);
+ }
+
+ private AddNumbersPortType getPort() {
+ 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.getAddNumbersPort(new AddressingFeature());
+ }
+}
Modified: incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers.wsdl?rev=598570&r1=598569&r2=598570&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers.wsdl (original)
+++ incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers.wsdl Tue Nov 27 01:40:04 2007
@@ -84,11 +84,11 @@
<output message="tns:addNumbersResponse"/>
<!-- <fault name="addNumbersFault" message="tns:addNumbersFault"/> -->
</operation>
-<!-- <operation name="addNumbers2"> -->
-<!-- <input message="tns:addNumbers2" name="add2In"/> -->
-<!-- <output message="tns:addNumbers2Response" name="add2Out"/> -->
+ <operation name="addNumbers2">
+ <input message="tns:addNumbers2" name="add2In"/>
+ <output message="tns:addNumbers2Response" name="add2Out"/>
<!-- <fault name="addNumbersFault" message="tns:addNumbersFault"/> -->
-<!-- </operation> -->
+ </operation>
<!-- <operation name="addNumbers3"> -->
<!-- <input message="tns:addNumbers3" wsaw:Action="3in"/> -->
<!-- <output message="tns:addNumbers3Response" wsaw:Action="3out"/> -->
@@ -112,18 +112,18 @@
</fault>
-->
</operation>
-<!-- <operation name="addNumbers2"> -->
-<!-- <soap:operation soapAction="" /> -->
-<!-- <input> -->
-<!-- <soap:body use="literal" /> -->
-<!-- </input> -->
-<!-- <output> -->
-<!-- <soap:body use="literal" /> -->
-<!-- </output> -->
+ <operation name="addNumbers2">
+ <soap:operation soapAction="" />
+ <input>
+ <soap:body use="literal" />
+ </input>
+ <output>
+ <soap:body use="literal" />
+ </output>
<!-- <fault name="addNumbersFault"> -->
<!-- <soap:fault name="addNumbersFault" use="literal" /> -->
<!-- </fault> -->
-<!-- </operation> -->
+ </operation>
<!-- <operation name="addNumbers3"> -->
<!-- <soap:operation soapAction="" /> -->
<!-- <input> -->
Added: incubator/cxf/trunk/systests/src/test/resources/wsdl/pizza_service-options
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/resources/wsdl/pizza_service-options?rev=598570&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/resources/wsdl/pizza_service-options (added)
+++ incubator/cxf/trunk/systests/src/test/resources/wsdl/pizza_service-options Tue Nov 27 01:40:04 2007
@@ -0,0 +1 @@
+-exsh true
\ No newline at end of file