Author: klape
Date: 2011-10-28 15:49:55 -0400 (Fri, 28 Oct 2011)
New Revision: 15173
Added:
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/AbstractSpringConfiguredAutoRewriteSoapAddressTest.java
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/SpringConfiguredAutoRewriteSoapAddressTest.java
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/SpringConfiguredNoAutoRewriteSoapAddressTest.java
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/beans_autoRewriteSoapAddress.xml
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/beans_no_autoRewriteSoapAddress.xml
Modified:
thirdparty/cxf/branches/cxf-2.2.12/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
thirdparty/cxf/branches/cxf-2.2.12/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Log:
[JBPAPP-7452] soap:address rewrite from Spring configuration
Modified:
thirdparty/cxf/branches/cxf-2.2.12/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java 2011-10-28
11:10:44 UTC (rev 15172)
+++
thirdparty/cxf/branches/cxf-2.2.12/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java 2011-10-28
19:49:55 UTC (rev 15173)
@@ -57,6 +57,7 @@
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.transports.http.StemMatchingQueryHandler;
@@ -294,10 +295,10 @@
LOG,
base), e);
}
-
- Boolean rewriteSoapAddress = ei.getProperty("autoRewriteSoapAddress",
Boolean.class);
-
- if (rewriteSoapAddress != null && rewriteSoapAddress.booleanValue()) {
+
+ Object rewriteSoapAddress = ei.getProperty("autoRewriteSoapAddress");
+
+ if (rewriteSoapAddress != null &&
MessageUtils.isTrue(rewriteSoapAddress)) {
List<Element> serviceList =
DOMUtils.findAllElementsByTagNameNS(doc.getDocumentElement(),
"http://schemas.xmlsoap.org/wsdl/",
"service");
Modified:
thirdparty/cxf/branches/cxf-2.2.12/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java 2011-10-28
11:10:44 UTC (rev 15172)
+++
thirdparty/cxf/branches/cxf-2.2.12/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java 2011-10-28
19:49:55 UTC (rev 15173)
@@ -27,6 +27,7 @@
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.concurrent.Executor;
import java.util.logging.Logger;
@@ -317,6 +318,14 @@
// TODO is there a good place to put this key-string as a constant?
endpointInfo.setProperty("publishedEndpointUrl",
publishedEndpointUrl);
}
+
+ if (null != properties) {
+ for (Entry<String, Object> entry : properties.entrySet()) {
+ endpointInfo.setProperty(entry.getKey(), entry.getValue());
+ }
+ System.err.println("\n\n");
+ }
+
this.address = endpointInfo.getAddress();
}
serv.start();
Added:
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/AbstractSpringConfiguredAutoRewriteSoapAddressTest.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/AbstractSpringConfiguredAutoRewriteSoapAddressTest.java
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/AbstractSpringConfiguredAutoRewriteSoapAddressTest.java 2011-10-28
19:49:55 UTC (rev 15173)
@@ -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.handlers;
+
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.LinkedList;
+import java.util.List;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.test.AbstractCXFSpringTest;
+
+/**
+ *
+ */
+public abstract class AbstractSpringConfiguredAutoRewriteSoapAddressTest extends
AbstractCXFSpringTest {
+
+ private Document retrieveWsdlDocument(String hostname, String port) throws Exception
{
+ URL wsdlUrlLocalhost = new URL("http://" + hostname + ":" +
port + "/SpringEndpoint?wsdl");
+ URLConnection urlConnection = wsdlUrlLocalhost.openConnection();
+ return DOMUtils.readXml(urlConnection.getInputStream());
+ }
+
+ protected List<String> findAllServiceUrlsFromWsdl(String hostname, String port)
throws Exception {
+ Document wsdlDocument = retrieveWsdlDocument(hostname, port);
+ List<String> serviceUrls = new LinkedList<String>();
+ List<Element> serviceList =
DOMUtils.findAllElementsByTagNameNS(wsdlDocument.getDocumentElement(),
+
"http://schemas.xmlsoap.org/wsdl/",
+ "service");
+ for (Element serviceEl : serviceList) {
+ List<Element> portList =
DOMUtils.findAllElementsByTagNameNS(serviceEl,
+
"http://schemas.xmlsoap.org/wsdl/",
+ "port");
+ for (Element portEl : portList) {
+ List<Element> addressList =
DOMUtils.findAllElementsByTagNameNS(portEl,
+
"http://schemas.xmlsoap.org/wsdl/soap/",
+ "address");
+ for (Element addressEl : addressList) {
+ serviceUrls.add(addressEl.getAttribute("location"));
+ }
+ }
+ }
+ return serviceUrls;
+ }
+
+}
Added:
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/SpringConfiguredAutoRewriteSoapAddressTest.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/SpringConfiguredAutoRewriteSoapAddressTest.java
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/SpringConfiguredAutoRewriteSoapAddressTest.java 2011-10-28
19:49:55 UTC (rev 15173)
@@ -0,0 +1,62 @@
+/**
+ * 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.handlers;
+
+import java.util.List;
+
+import org.apache.cxf.testutil.common.TestUtil;
+import org.apache.handlers.AddNumbers;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class SpringConfiguredAutoRewriteSoapAddressTest
+ extends AbstractSpringConfiguredAutoRewriteSoapAddressTest {
+ static String port =
TestUtil.getPortNumber("springportAutoRewriteSoapAddressTest");
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]
{"classpath:/org/apache/cxf/systest/handlers/beans_autoRewriteSoapAddress.xml"
};
+ }
+
+ @Test
+ public void testWsdlAddress() throws Exception {
+ System.err.println("portNumber: " + port);
+
System.err.println(getApplicationContext().getBean("cxfHandlerTestEndpoint").
+
getClass().toString());
+
+ AddNumbers addNumbers =
(AddNumbers)getApplicationContext().getBean("cxfHandlerTestClientEndpoint",
+ AddNumbers.class);
+
+ int r = addNumbers.addNumbers(10, 15);
+ assertEquals(1015, r);
+
+
+ List<String> serviceUrls =
findAllServiceUrlsFromWsdl("localhost", port);
+ assertEquals(1, serviceUrls.size());
+ assertEquals("http://localhost:" + port + "/SpringEndpoint",
serviceUrls.get(0));
+
+ serviceUrls = findAllServiceUrlsFromWsdl("127.0.0.1", port);
+ assertEquals(1, serviceUrls.size());
+ assertEquals("http://127.0.0.1:" + port + "/SpringEndpoint",
serviceUrls.get(0));
+
+ }
+}
Added:
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/SpringConfiguredNoAutoRewriteSoapAddressTest.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/SpringConfiguredNoAutoRewriteSoapAddressTest.java
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/SpringConfiguredNoAutoRewriteSoapAddressTest.java 2011-10-28
19:49:55 UTC (rev 15173)
@@ -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.handlers;
+
+import java.util.List;
+
+import org.apache.cxf.testutil.common.TestUtil;
+import org.apache.handlers.AddNumbers;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class SpringConfiguredNoAutoRewriteSoapAddressTest
+ extends AbstractSpringConfiguredAutoRewriteSoapAddressTest {
+ static String port =
TestUtil.getPortNumber("springportNoAutoRewriteSoapAddressTest");
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]
+
{"classpath:/org/apache/cxf/systest/handlers/beans_no_autoRewriteSoapAddress.xml"
};
+ }
+
+ @Test
+ public void testWsdlAddress() throws Exception {
+ System.err.println("portNumber: " + port);
+
System.err.println(getApplicationContext().getBean("cxfHandlerTestEndpoint").
+
getClass().toString());
+
+ AddNumbers addNumbers =
(AddNumbers)getApplicationContext().getBean("cxfHandlerTestClientEndpoint",
+ AddNumbers.class);
+
+ int r = addNumbers.addNumbers(10, 15);
+ assertEquals(1015, r);
+
+
+ List<String> serviceUrls =
findAllServiceUrlsFromWsdl("localhost", port);
+ assertEquals(1, serviceUrls.size());
+ assertEquals("http://localhost:" + port + "/SpringEndpoint",
serviceUrls.get(0));
+
+ serviceUrls = findAllServiceUrlsFromWsdl("127.0.0.1", port);
+ assertEquals(1, serviceUrls.size());
+ assertEquals("http://localhost:" + port + "/SpringEndpoint",
serviceUrls.get(0));
+
+ }
+
+}
Added:
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/beans_autoRewriteSoapAddress.xml
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/beans_autoRewriteSoapAddress.xml
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/beans_autoRewriteSoapAddress.xml 2011-10-28
19:49:55 UTC (rev 15173)
@@ -0,0 +1,77 @@
+<?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.
+-->
+<beans
xmlns="http://www.springframework.org/schema/beans"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xmlns:jaxws="http://cxf.apache.org/jaxws"
+xmlns:cxf="http://cxf.apache.org/core"
+xsi:schemaLocation="
+http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd
+http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
+<import resource="classpath:META-INF/cxf/cxf.xml" />
+<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
+<import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
+<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml" />
+
+ <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+
+ <jaxws:endpoint id="cxfHandlerTestEndpoint"
+ implementor="org.apache.cxf.systest.handlers.AddNumbersNoHandlers"
+ address="http://localhost:${testutil.ports.springportAutoRewriteSoapAddressTest}/SpringEndpoint">
+ <jaxws:handlers>
+ <bean
class="org.apache.cxf.systest.handlers.ModifyNumberHandler"/>
+ </jaxws:handlers>
+ <jaxws:properties>
+ <entry key="autoRewriteSoapAddress"
value="true"/>
+ </jaxws:properties>
+ </jaxws:endpoint>
+ <jaxws:server id="cxfHandlerTestServer"
+ serviceClass="org.apache.handlers.AddNumbers"
+ address="http://localhost:${testutil.ports.springportAutoRewriteSoapAddressTest}/SpringServer">
+ <jaxws:serviceBean>
+ <bean
class="org.apache.cxf.systest.handlers.AddNumbersNoHandlers" />
+ </jaxws:serviceBean>
+
+ <jaxws:handlers>
+ <bean
class="org.apache.cxf.systest.handlers.ModifyNumberHandler"/>
+ </jaxws:handlers>
+ </jaxws:server>
+
+ <jaxws:client id="cxfHandlerTestClientEndpoint"
+ serviceClass="org.apache.handlers.AddNumbers"
+
address="http://localhost:${testutil.ports.springportAutoRewriteSoapAddressTest}/SpringEndpoint">
+ <jaxws:handlers>
+ <bean
class="org.apache.cxf.systest.handlers.ModifyNumberHandler"/>
+ </jaxws:handlers>
+ </jaxws:client>
+ <jaxws:client id="cxfHandlerTestClientEndpointNoHandler"
+ serviceClass="org.apache.handlers.AddNumbers"
+
address="http://localhost:${testutil.ports.springportAutoRewriteSoapAddressTest}/SpringEndpoint">
+ </jaxws:client>
+ <jaxws:client id="cxfHandlerTestClientServer"
+ serviceClass="org.apache.handlers.AddNumbers"
+
address="http://localhost:${testutil.ports.springportAutoRewriteSoapAddressTest}/SpringServer">
+ <jaxws:handlers>
+ <bean
class="org.apache.cxf.systest.handlers.ModifyNumberHandler"/>
+ </jaxws:handlers>
+ </jaxws:client>
+
+</beans>
Added:
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/beans_no_autoRewriteSoapAddress.xml
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/beans_no_autoRewriteSoapAddress.xml
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/beans_no_autoRewriteSoapAddress.xml 2011-10-28
19:49:55 UTC (rev 15173)
@@ -0,0 +1,74 @@
+<?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.
+-->
+<beans
xmlns="http://www.springframework.org/schema/beans"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xmlns:jaxws="http://cxf.apache.org/jaxws"
+xmlns:cxf="http://cxf.apache.org/core"
+xsi:schemaLocation="
+http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd
+http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
+<import resource="classpath:META-INF/cxf/cxf.xml" />
+<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
+<import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
+<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml" />
+
+ <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+
+ <jaxws:endpoint id="cxfHandlerTestEndpoint"
+ implementor="org.apache.cxf.systest.handlers.AddNumbersNoHandlers"
+ address="http://localhost:${testutil.ports.springportNoAutoRewriteSoapAddressTest}/SpringEndpoint">
+ <jaxws:handlers>
+ <bean
class="org.apache.cxf.systest.handlers.ModifyNumberHandler"/>
+ </jaxws:handlers>
+ </jaxws:endpoint>
+ <jaxws:server id="cxfHandlerTestServer"
+ serviceClass="org.apache.handlers.AddNumbers"
+ address="http://localhost:${testutil.ports.springportNoAutoRewriteSoapAddressTest}/SpringServer">
+ <jaxws:serviceBean>
+ <bean
class="org.apache.cxf.systest.handlers.AddNumbersNoHandlers" />
+ </jaxws:serviceBean>
+
+ <jaxws:handlers>
+ <bean
class="org.apache.cxf.systest.handlers.ModifyNumberHandler"/>
+ </jaxws:handlers>
+ </jaxws:server>
+
+ <jaxws:client id="cxfHandlerTestClientEndpoint"
+ serviceClass="org.apache.handlers.AddNumbers"
+
address="http://localhost:${testutil.ports.springportNoAutoRewriteSoapAddressTest}/SpringEndpoint">
+ <jaxws:handlers>
+ <bean
class="org.apache.cxf.systest.handlers.ModifyNumberHandler"/>
+ </jaxws:handlers>
+ </jaxws:client>
+ <jaxws:client id="cxfHandlerTestClientEndpointNoHandler"
+ serviceClass="org.apache.handlers.AddNumbers"
+
address="http://localhost:${testutil.ports.springportNoAutoRewriteSoapAddressTest}/SpringEndpoint">
+ </jaxws:client>
+ <jaxws:client id="cxfHandlerTestClientServer"
+ serviceClass="org.apache.handlers.AddNumbers"
+
address="http://localhost:${testutil.ports.springportNoAutoRewriteSoapAddressTest}/SpringServer">
+ <jaxws:handlers>
+ <bean
class="org.apache.cxf.systest.handlers.ModifyNumberHandler"/>
+ </jaxws:handlers>
+ </jaxws:client>
+
+</beans>