Author: richard.opalka(a)jboss.com
Date: 2010-02-19 07:20:10 -0500 (Fri, 19 Feb 2010)
New Revision: 11641
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-2937][JBWS-2914] fixing wrong NativeEndpointReference deserialization
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-02-19
11:32:09 UTC (rev 11640)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/NativeEndpointReference.java 2010-02-19
12:20:10 UTC (rev 11641)
@@ -135,21 +135,18 @@
{
if (WSAM_NS.equals(e.getNamespaceURI()))
{
- if (e.getNodeName().equals(SERVICE_QNAME.getLocalPart()))
+ if (e.getLocalName().equals(SERVICE_QNAME.getLocalPart()))
{
- QName serviceQName = this.getQName(e, e.getNodeValue());
- this.setServiceName(serviceQName);
+ this.serviceName = this.getQName(e, e.getTextContent());
String endpointName = e.getAttribute(ENDPOINT_ATTRIBUTE);
if (endpointName != null)
{
- QName endpointQName = this.getQName(e, endpointName);
- this.setEndpointName(endpointQName);
+ this.endpointName = this.getQName(e, endpointName);
}
}
- if (e.getNodeName().equals(INTERFACE_QNAME.getLocalPart()))
+ if (e.getLocalName().equals(INTERFACE_QNAME.getLocalPart()))
{
- QName interfaceQName = this.getQName(e, e.getNodeValue());
- this.setServiceName(interfaceQName);
+ this.interfaceName = this.getQName(e, e.getTextContent());
}
}
}
@@ -193,7 +190,7 @@
this.serviceName = serviceName;
this.serviceNameElement = DOMUtils.createElement(SERVICE_QNAME);
- final String attrName = "xmlns:" + serviceName.getPrefix();
+ final String attrName = this.getNamespaceAttributeName(serviceName.getPrefix());
this.serviceNameElement.setAttribute(attrName, serviceName.getNamespaceURI());
this.serviceNameElement.setTextContent(this.toString(serviceName));
this.metadata.addElement(this.serviceNameElement);
@@ -226,7 +223,7 @@
this.interfaceName = interfaceName;
Element interfaceNameElement = DOMUtils.createElement(INTERFACE_QNAME);
- final String attrName = "xmlns:" + interfaceName.getPrefix();
+ final String attrName = this.getNamespaceAttributeName(interfaceName.getPrefix());
interfaceNameElement.setAttribute(attrName, interfaceName.getNamespaceURI());
interfaceNameElement.setTextContent(this.toString(interfaceName));
this.metadata.addElement(interfaceNameElement);
@@ -314,7 +311,7 @@
*/
public void writeTo(Result result)
{
- if (this.endpointName != null && this.serviceName != null)
+ if (this.endpointName != null && this.serviceNameElement != null)
{
this.serviceNameElement.setAttribute(ENDPOINT_ATTRIBUTE,
this.toString(this.endpointName));
}
@@ -368,10 +365,14 @@
private QName getQName(Element e, String nodeValue)
{
+ if (nodeValue == null)
+ throw new RuntimeException("Missing text content for element: " +
e.getNodeName());
+
final int separatorIndex = nodeValue.indexOf(':');
if (separatorIndex == -1)
{
- return new QName(nodeValue);
+ final String namespace = e.getAttribute("xmlns");
+ return new QName(namespace, nodeValue);
}
else
{
@@ -382,6 +383,14 @@
}
}
+ private String getNamespaceAttributeName(final String prefix)
+ {
+ if (prefix == null || "".equals(prefix))
+ return "xmlns";
+
+ return "xmlns:" + prefix;
+ }
+
private static class Address
{
@XmlValue
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-02-19
11:32:09 UTC (rev 11640)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/epr/NativeEndpointReferenceTestCase.java 2010-02-19
12:20:10 UTC (rev 11641)
@@ -81,6 +81,9 @@
assertMetaData(endpointReferenceElement);
assertRefParam(endpointReferenceElement, PARAM1_QNAME, "Hello");
assertRefParam(endpointReferenceElement, PARAM2_QNAME, "World");
+ assertEquals(new QName(MY_NS, "HelloService", MY_PREFIX),
epr.getServiceName());
+ assertEquals(new QName(MY_NS, "Hello", MY_PREFIX),
epr.getInterfaceName());
+ assertEquals(new QName(MY_NS, "HelloPort", MY_PREFIX),
epr.getEndpointName());
}
private static void assertRefParam(final Node root, final QName nodeName, final String
refParamValue)