Author: alessio.soldano(a)jboss.com
Date: 2009-10-13 13:22:20 -0400 (Tue, 13 Oct 2009)
New Revision: 10903
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl/jmsservice.wsdl
Removed:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl/jmsservice.wsdl
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2268/JBWS2268TestCase.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl
Log:
[JBPAPP-2912] JBossWS - Malformed URL exception when deploying wsdl with jms address
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2009-10-13
17:20:01 UTC (rev 10902)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2009-10-13
17:22:20 UTC (rev 10903)
@@ -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 EndpointMetaData epMetaData;
@@ -207,25 +209,28 @@
{
String orgLocation = locationAttr.getNodeValue();
- URL orgURL = new URL(orgLocation);
- String orgHost = orgURL.getHost();
- String orgPath = orgURL.getPath();
+ if (isHttp(orgLocation))
+ {
+ URL orgURL = new URL(orgLocation);
+ String orgHost = orgURL.getHost();
+ String orgPath = orgURL.getPath();
- if (ServerConfig.UNDEFINED_HOSTNAME.equals(orgHost))
- {
- URL newURL = new URL(wsdlHost);
- String newProtocol = newURL.getProtocol();
- String newHost = newURL.getHost();
- int newPort = newURL.getPort();
+ if (ServerConfig.UNDEFINED_HOSTNAME.equals(orgHost))
+ {
+ URL newURL = new URL(wsdlHost);
+ String newProtocol = newURL.getProtocol();
+ String newHost = newURL.getHost();
+ int newPort = newURL.getPort();
- String newLocation = newProtocol + "://" + newHost;
- if (newPort != -1)
- newLocation += ":" + newPort;
+ String newLocation = newProtocol + "://" + newHost;
+ if (newPort != -1)
+ newLocation += ":" + newPort;
- newLocation += orgPath;
- locationAttr.setNodeValue(newLocation);
+ newLocation += orgPath;
+ locationAttr.setNodeValue(newLocation);
- log.trace("Mapping address from '" + orgLocation +
"' to '" + newLocation + "'");
+ log.trace("Mapping address from '" + orgLocation +
"' to '" + newLocation + "'");
+ }
}
}
}
@@ -237,4 +242,26 @@
}
}
+ 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;
+ }
+ }
+
}
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2009-10-13
17:20:01 UTC (rev 10902)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2009-10-13
17:22:20 UTC (rev 10903)
@@ -313,15 +313,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)
- {
log.debug("Replace service endpoint address '" +
orgAddress + "' with '" + serviceEndpointURL + "'");
wsdlEndpoint.setAddress(serviceEndpointURL);
sepMetaData.setEndpointAddress(serviceEndpointURL);
@@ -339,7 +335,8 @@
}
catch (MalformedURLException e)
{
- throw new WSException("Malformed URL: " + orgAddress);
+ log.warn("Malformed URL: " + orgAddress);
+ sepMetaData.setEndpointAddress(orgAddress);
}
}
}
@@ -349,6 +346,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/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml 2009-10-13
17:20:01 UTC (rev 10902)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml 2009-10-13
17:22:20 UTC (rev 10903)
@@ -119,6 +119,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/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2268/JBWS2268TestCase.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2268/JBWS2268TestCase.java 2009-10-13
17:20:01 UTC (rev 10902)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2268/JBWS2268TestCase.java 2009-10-13
17:22:20 UTC (rev 10903)
@@ -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/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java 2009-10-13
17:20:01 UTC (rev 10902)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java 2009-10-13
17:22:20 UTC (rev 10903)
@@ -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/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java 2009-10-13
17:20:01 UTC (rev 10902)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java 2009-10-13
17:22:20 UTC (rev 10903)
@@ -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)
Copied:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl
(from rev 10890,
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl)
Deleted:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl/jmsservice.wsdl
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl/jmsservice.wsdl 2009-10-12
13:24:25 UTC (rev 10890)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl/jmsservice.wsdl 2009-10-13
17:22:20 UTC (rev 10903)
@@ -1,55 +0,0 @@
-<definitions name='OrganizationJMSEndpointService'
targetNamespace='http://org.jboss.ws/samples/jmstransport'
xmlns='http://schemas.xmlsoap.org/wsdl/'
-
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://org.jboss.ws/samples/jmstransport'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
-
- <types></types>
-
- <message name='OrganizationJMSEndpoint_getContactInfoResponse'>
- <part name='return' type='xsd:string'></part>
- </message>
- <message name='OrganizationJMSEndpoint_getContactInfo'>
- <part name='arg0' type='xsd:string'></part>
- </message>
-
- <portType name='OrganizationJMSEndpoint'>
- <operation name='getContactInfo' parameterOrder='arg0'>
- <input
message='tns:OrganizationJMSEndpoint_getContactInfo'></input>
- <output
message='tns:OrganizationJMSEndpoint_getContactInfoResponse'></output>
- </operation>
- </portType>
-
- <binding name='HTTPBinding' type='tns:OrganizationJMSEndpoint'>
- <soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
- <operation name='getContactInfo'>
- <soap:operation soapAction=''/>
- <input>
- <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
- </input>
- <output>
- <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
- </output>
- </operation>
- </binding>
-
- <binding name='JMSBinding' type='tns:OrganizationJMSEndpoint'>
- <soap:binding style='rpc'
transport='http://www.example.org/2006/06/soap/bindings/JMS/'/>
- <operation name='getContactInfo'>
- <soap:operation soapAction=''/>
- <input>
- <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
- </input>
- <output>
- <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
- </output>
- </operation>
- </binding>
-
- <service name='OrganizationJMSEndpointService'>
- <port binding='tns:HTTPBinding' name='HTTPEndpointPort'>
- <soap:address
location='http://@jboss.bind.address@:8080/jaxws-samples-jmstransport/OrganizationJMSEndpoint'/>
- </port>
- <port binding='tns:JMSBinding'
name='OrganizationJMSEndpointPort'>
- <soap:address
location='jms://queue/RequestQueue?replyToName=queue/ResponseQueue'/>
- </port>
- </service>
-
-</definitions>
\ No newline at end of file
Copied:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl/jmsservice.wsdl
(from rev 10890,
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl/jmsservice.wsdl)
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl/jmsservice.wsdl
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/META-INF/wsdl/jmsservice.wsdl 2009-10-13
17:22:20 UTC (rev 10903)
@@ -0,0 +1,55 @@
+<definitions name='OrganizationJMSEndpointService'
targetNamespace='http://org.jboss.ws/samples/jmstransport'
xmlns='http://schemas.xmlsoap.org/wsdl/'
+
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://org.jboss.ws/samples/jmstransport'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+
+ <types></types>
+
+ <message name='OrganizationJMSEndpoint_getContactInfoResponse'>
+ <part name='return' type='xsd:string'></part>
+ </message>
+ <message name='OrganizationJMSEndpoint_getContactInfo'>
+ <part name='arg0' type='xsd:string'></part>
+ </message>
+
+ <portType name='OrganizationJMSEndpoint'>
+ <operation name='getContactInfo' parameterOrder='arg0'>
+ <input
message='tns:OrganizationJMSEndpoint_getContactInfo'></input>
+ <output
message='tns:OrganizationJMSEndpoint_getContactInfoResponse'></output>
+ </operation>
+ </portType>
+
+ <binding name='HTTPBinding' type='tns:OrganizationJMSEndpoint'>
+ <soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='getContactInfo'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
+ </input>
+ <output>
+ <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
+ </output>
+ </operation>
+ </binding>
+
+ <binding name='JMSBinding' type='tns:OrganizationJMSEndpoint'>
+ <soap:binding style='rpc'
transport='http://www.example.org/2006/06/soap/bindings/JMS/'/>
+ <operation name='getContactInfo'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
+ </input>
+ <output>
+ <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name='OrganizationJMSEndpointService'>
+ <port binding='tns:HTTPBinding' name='HTTPEndpointPort'>
+ <soap:address
location='http://@jboss.bind.address@:8080/jaxws-samples-jmstransport/OrganizationJMSEndpoint'/>
+ </port>
+ <port binding='tns:JMSBinding'
name='OrganizationJMSEndpointPort'>
+ <soap:address
location='jms://queue/RequestQueue?replyToName=queue/ResponseQueue'/>
+ </port>
+ </service>
+
+</definitions>
\ No newline at end of file
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl 2009-10-13
17:20:01 UTC (rev 10902)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl 2009-10-13
17:22:20 UTC (rev 10903)
@@ -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>