Author: alessio.soldano(a)jboss.com
Date: 2009-10-12 09:23:34 -0400 (Mon, 12 Oct 2009)
New Revision: 10889
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
stack/native/trunk/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2268/JBWS2268TestCase.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl
Log:
[JBWS-2783] Do not try to rewrite jms endpoints
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2009-10-12
13:08:34 UTC (rev 10888)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2009-10-12
13:23:34 UTC (rev 10889)
@@ -23,6 +23,8 @@
import java.io.File;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import org.jboss.logging.Logger;
@@ -52,7 +54,7 @@
public class WSDLRequestHandler
{
// provide logging
- private Logger log = Logger.getLogger(WSDLRequestHandler.class);
+ private static Logger log = Logger.getLogger(WSDLRequestHandler.class);
private final EndpointMetaData epMetaData;
private final ServerConfig config;
@@ -211,23 +213,26 @@
{
String orgLocation = locationAttr.getNodeValue();
- URL orgURL = new URL(orgLocation);
- String protocol = orgURL.getProtocol();
- String host = orgURL.getHost();
- int port = getPortForProtocol(protocol);
- String path = orgURL.getPath();
- final boolean rewriteLocation =
- ServerConfig.UNDEFINED_HOSTNAME.equals(host) ||
- this.config.isModifySOAPAddress();
-
- if (rewriteLocation)
+ if (isHttp(orgLocation))
{
- String newLocation = new URL(protocol, wsdlHost, port,
path).toString();
- if (!newLocation.equals(orgLocation))
+ URL orgURL = new URL(orgLocation);
+ String protocol = orgURL.getProtocol();
+ String host = orgURL.getHost();
+ int port = getPortForProtocol(protocol);
+ String path = orgURL.getPath();
+ final boolean rewriteLocation =
+ ServerConfig.UNDEFINED_HOSTNAME.equals(host) ||
+ this.config.isModifySOAPAddress();
+
+ if (rewriteLocation)
{
- locationAttr.setNodeValue(newLocation);
- if (log.isDebugEnabled())
- log.debug("Mapping address from '" + orgLocation
+ "' to '" + newLocation + "'");
+ String newLocation = new URL(protocol, wsdlHost, port,
path).toString();
+ if (!newLocation.equals(orgLocation))
+ {
+ locationAttr.setNodeValue(newLocation);
+ if (log.isDebugEnabled())
+ log.debug("Mapping address from '" +
orgLocation + "' to '" + newLocation + "'");
+ }
}
}
}
@@ -239,6 +244,28 @@
}
}
}
+
+ private static boolean isHttp(String orgLocation)
+ {
+ try
+ {
+ String scheme = new URI(orgLocation).getScheme();
+ if (scheme != null && scheme.startsWith("http"))
+ {
+ return true;
+ }
+ else
+ {
+ log.info("Skipping rewrite of non-http address: " + orgLocation);
+ return false;
+ }
+ }
+ catch (URISyntaxException e)
+ {
+ log.error("Skipping rewrite of invalid address: " + orgLocation, e);
+ return false;
+ }
+ }
/**
* Returns real http and https protocol values. Returns -1 for non http(s) protocols.
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2009-10-12
13:08:34 UTC (rev 10888)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2009-10-12
13:23:34 UTC (rev 10889)
@@ -319,15 +319,11 @@
if ("CONFIDENTIAL".equals(transportGuarantee))
uriScheme = "https";
- String servicePath = sepMetaData.getContextRoot() +
sepMetaData.getURLPattern();
- String serviceEndpointURL = getServiceEndpointAddress(uriScheme,
servicePath);
+ if (requiresRewrite(orgAddress, uriScheme))
+ {
+ String servicePath = sepMetaData.getContextRoot() +
sepMetaData.getURLPattern();
+ String serviceEndpointURL = getServiceEndpointAddress(uriScheme,
servicePath);
- SPIProvider spiProvider =
SPIProviderResolver.getInstance().getProvider();
- ServerConfig config =
spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
- boolean alwaysModify = config.isModifySOAPAddress();
-
- if (alwaysModify || uriScheme == null ||
orgAddress.indexOf("REPLACE_WITH_ACTUAL_URL") >= 0)
- {
if (log.isDebugEnabled())
log.debug("Replace service endpoint address '" +
orgAddress + "' with '" + serviceEndpointURL + "'");
wsdlEndpoint.setAddress(serviceEndpointURL);
@@ -347,7 +343,8 @@
}
catch (MalformedURLException e)
{
- throw new WSException("Malformed URL: " + orgAddress);
+ log.warn("Malformed URL: " + orgAddress);
+ sepMetaData.setEndpointAddress(orgAddress);
}
}
}
@@ -357,6 +354,23 @@
if (endpointFound == false)
throw new WSException("Cannot find port in wsdl: " + portName);
}
+
+ private static boolean requiresRewrite(String orgAddress, String uriScheme)
+ {
+ if (uriScheme != null)
+ {
+ if (!uriScheme.toLowerCase().startsWith("http"))
+ {
+ //perform rewrite on http/https addresses only
+ return false;
+ }
+ }
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ ServerConfig config =
spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
+ boolean alwaysModify = config.isModifySOAPAddress();
+
+ return (alwaysModify || uriScheme == null ||
orgAddress.indexOf("REPLACE_WITH_ACTUAL_URL") >= 0);
+ }
private static void replaceWSDL11PortAddress(WSDLDefinitions wsdlDefinitions, QName
portQName, String serviceEndpointURL)
{
Modified:
stack/native/trunk/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml 2009-10-12
13:08:34 UTC (rev 10888)
+++
stack/native/trunk/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml 2009-10-12
13:23:34 UTC (rev 10889)
@@ -127,6 +127,9 @@
<include
name="org/jboss/test/ws/jaxws/samples/jmstransport/Organization.class"/>
<include
name="org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.class"/>
</fileset>
+ <metainf
dir="${tests.output.dir}/test-resources/jaxws/samples/jmstransport/META-INF">
+ <include name="wsdl/*.wsdl"/>
+ </metainf>
</jar>
<jar
jarfile="${tests.output.dir}/test-libs/jaxws-samples-jmstransport.sar">
<fileset dir="${tests.output.dir}/test-libs">
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2268/JBWS2268TestCase.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2268/JBWS2268TestCase.java 2009-10-12
13:08:34 UTC (rev 10888)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2268/JBWS2268TestCase.java 2009-10-12
13:23:34 UTC (rev 10889)
@@ -86,7 +86,7 @@
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copyStream(baos, new FileInputStream(logFile));
- assertEquals(baos.toString().trim(), "init() destroy()");
+ assertEquals("init() destroy()", baos.toString().trim());
logFile.delete();
}
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java 2009-10-12
13:08:34 UTC (rev 10888)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java 2009-10-12
13:23:34 UTC (rev 10889)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.ws.jaxws.samples.jmstransport;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
import java.net.URL;
import javax.jms.Message;
@@ -37,12 +39,12 @@
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
+import junit.framework.Test;
+
+import org.jboss.wsf.common.DOMUtils;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestSetup;
-import org.jboss.wsf.common.DOMUtils;
-import junit.framework.Test;
-
/**
* A web service client that connects to a MDB endpoint.
*
@@ -57,12 +59,26 @@
{
return new JBossWSTestSetup(JMSTransportTestCase.class,
"jaxws-samples-jmstransport.sar");
}
+
+ public void testPublishedContract() throws Exception
+ {
+ //test the published contract using the 2nd port, which is an http one
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-samples-jmstransport/OrganizationJMSEndpoint?wsdl");
+ StringBuilder sb = new StringBuilder();
+ BufferedReader reader = new BufferedReader(new
InputStreamReader(wsdlURL.openStream()));
+ String line;
+ while ((line = reader.readLine()) != null)
+ {
+ sb.append(line);
+ }
+
assertTrue(sb.toString().contains("jms://queue/RequestQueue?replyToName=queue/ResponseQueue"));
+ }
public void testJMSEndpointPort() throws Exception
{
URL wsdlURL =
getResourceURL("jaxws/samples/jmstransport/jmsservice.wsdl");
QName serviceName = new QName("http://org.jboss.ws/samples/jmstransport",
"OrganizationJMSEndpointService");
- QName portName = new QName("http://org.jboss.ws/samples/jmstransport",
"JMSEndpointPort");
+ QName portName = new QName("http://org.jboss.ws/samples/jmstransport",
"OrganizationJMSEndpointPort");
Service service = Service.create(wsdlURL, serviceName);
Organization port = service.getPort(portName, Organization.class);
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java 2009-10-12
13:08:34 UTC (rev 10888)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java 2009-10-12
13:23:34 UTC (rev 10889)
@@ -40,7 +40,7 @@
* @author Thomas.Diesler(a)jboss.org
* @since 09-Jan-2008
*/
-@WebService (targetNamespace = "http://org.jboss.ws/samples/jmstransport")
+@WebService (targetNamespace = "http://org.jboss.ws/samples/jmstransport",
wsdlLocation="META-INF/wsdl/jmsservice.wsdl")
@WebContext (contextRoot = "/jaxws-samples-jmstransport")
@SOAPBinding(style = SOAPBinding.Style.RPC)
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl 2009-10-12
13:08:34 UTC (rev 10888)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl 2009-10-12
13:23:34 UTC (rev 10889)
@@ -47,7 +47,7 @@
<port binding='tns:HTTPBinding' name='HTTPEndpointPort'>
<soap:address
location='http://@jboss.bind.address@:8080/jaxws-samples-jmstransport/OrganizationJMSEndpoint'/>
</port>
- <port binding='tns:JMSBinding' name='JMSEndpointPort'>
+ <port binding='tns:JMSBinding'
name='OrganizationJMSEndpointPort'>
<soap:address
location='jms://queue/RequestQueue?replyToName=queue/ResponseQueue'/>
</port>
</service>