Author: richard.opalka(a)jboss.com
Date: 2010-05-26 09:27:20 -0400 (Wed, 26 May 2010)
New Revision: 12344
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/NativeEndpointReference.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/epr/NativeEndpointReferenceTestCase.java
Log:
[JBWS-2914] wsdlLocation in EPR have to be namespace qualified
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/NativeEndpointReference.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/NativeEndpointReference.java 2010-05-26
13:24:44 UTC (rev 12343)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/NativeEndpointReference.java 2010-05-26
13:27:20 UTC (rev 12344)
@@ -65,9 +65,10 @@
{
protected static final String WSA_NS =
"http://www.w3.org/2005/08/addressing";
private static final String WSAM_NS =
"http://www.w3.org/2007/05/addressing/metadata";
+ private static final String WSDLI_NS =
"http://www.w3.org/ns/wsdl-instance";
private static final QName SERVICE_QNAME = new QName(WSAM_NS, "ServiceName",
"wsam");
private static final QName INTERFACE_QNAME = new QName(WSAM_NS,
"InterfaceName", "wsam");
- private static final QName WSDL_LOCATION_QNAME = new QName("wsdlLocation");
+ private static final QName WSDL_LOCATION_QNAME = new QName(WSDLI_NS,
"wsdlLocation", "wsdli");
private static final String ENDPOINT_ATTRIBUTE = "EndpointName";
private static final JAXBContext jc = getJaxbContext();
@@ -131,7 +132,11 @@
final String wsdlLocation = metadataAttributes.get(WSDL_LOCATION_QNAME);
if (wsdlLocation != null)
{
- this.setWsdlLocation(wsdlLocation);
+ int spaceIndex = wsdlLocation.indexOf(" ");
+ if (spaceIndex == -1)
+ throw new IllegalArgumentException("wsdlLocation have to
specify both wsdl namespace and target wsdl location");
+
+ this.setWsdlLocation(wsdlLocation.substring(spaceIndex).trim());
}
}
List<Element> metadataElements = epr.metadata.getElements();
@@ -286,10 +291,6 @@
return;
this.wsdlLocation = wsdlLocation;
- if (this.metadata == null)
- this.metadata = new Elements();
-
- this.metadata.addAttribute(WSDL_LOCATION_QNAME, wsdlLocation);
}
@XmlTransient
@@ -341,6 +342,27 @@
if (this.endpointName != null && this.serviceNameElement != null)
{
this.serviceNameElement.setAttribute(ENDPOINT_ATTRIBUTE,
this.toString(this.endpointName));
+
+ if (this.wsdlLocation != null)
+ {
+ if (this.metadata == null)
+ this.metadata = new Elements();
+
+ String wsdlNamespace = null;
+ if (this.endpointName != null)
+ {
+ wsdlNamespace = this.endpointName.getNamespaceURI();
+ }
+ else if (this.serviceName != null)
+ {
+ wsdlNamespace = this.serviceName.getNamespaceURI();
+ }
+
+ if (wsdlNamespace == null && this.wsdlLocation != null)
+ throw new IllegalStateException("Either serviceName or endpointName
have to be specified when providing wsdlLocation");
+
+ this.metadata.addAttribute(WSDL_LOCATION_QNAME, wsdlNamespace + " "
+ this.wsdlLocation);
+ }
}
try
{
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/epr/NativeEndpointReferenceTestCase.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/epr/NativeEndpointReferenceTestCase.java 2010-05-26
13:24:44 UTC (rev 12343)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/epr/NativeEndpointReferenceTestCase.java 2010-05-26
13:27:20 UTC (rev 12344)
@@ -21,18 +21,13 @@
*/
package org.jboss.test.ws.jaxws.epr;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
-import org.jboss.ws.Constants;
import org.jboss.ws.core.jaxws.wsaddressing.NativeEndpointReference;
import org.jboss.wsf.common.DOMUtils;
-import org.jboss.wsf.common.DOMWriter;
import org.jboss.wsf.test.JBossWSTest;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -63,7 +58,7 @@
" <ns1:param1 wsa:IsReferenceParameter='true'
xmlns:ns1='http://helloservice.org/param1'
xmlns:wsa='http://www.w3.org/2005/08/addressing'>Hello</ns1...
+
" <ns2:param2 wsa:IsReferenceParameter='true'
xmlns:ns2='http://helloservice.org/param2'
xmlns:wsa='http://www.w3.org/2005/08/addressing'>World</ns2...
+
" </ReferenceParameters>" +
- " <Metadata
wsdlLocation='http://localhost:8080/hello?wsdl'>" +
+ " <Metadata
wsdli:wsdlLocation='http://helloservice.org/wsdl
http://localhost:8080/hello?wsdl'
xmlns:wsdli='http://www.w3.org/ns/wsdl-instance'>" +
" <wsam:ServiceName EndpointName='myns:HelloPort'
xmlns:myns='http://helloservice.org/wsdl'
xmlns:wsam='http://www.w3.org/2007/05/addressing/metadata'>myn...
+
" <wsam:InterfaceName
xmlns:myns='http://helloservice.org/wsdl'
xmlns:wsam='http://www.w3.org/2007/05/addressing/metadata'>myn...
+
" </Metadata>" +
@@ -100,7 +95,8 @@
private static void assertMetaData(final Node root)
{
Element metadataElement = (Element)DOMUtils.getFirstChildElement(root,
METADATA_QNAME, true);
- assertEquals("wsdlLocation mismatch",
metadataElement.getAttribute("wsdlLocation"), WSDL_URL);
+ String wsdlLocationValue =
metadataElement.getAttributeNodeNS("http://www.w3.org/ns/wsdl-instan...;,
"wsdlLocation").getValue();
+ assertEquals("wsdlLocation mismatch", wsdlLocationValue, MY_NS + "
" + WSDL_URL);
Element serviceNameElement =
(Element)DOMUtils.getFirstChildElement(metadataElement, WSAM_SERVICE_QNAME);
assertNamespaces(serviceNameElement);
assertEquals("wrong text content in ServiceName element",
"myns:HelloService", DOMUtils.getTextContent(serviceNameElement));