Author: jim.ma
Date: 2012-04-24 02:33:29 -0400 (Tue, 24 Apr 2012)
New Revision: 16206
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/epr/NativeEndpointReferenceTestCase.java
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/EndpointReferenceUtil.java
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/NativeEndpointReference.java
Log:
[JBPAPP-8810]:Back port the fix for JBWS-2937
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java 2012-04-20
15:05:19 UTC (rev 16205)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java 2012-04-24
06:33:29 UTC (rev 16206)
@@ -24,6 +24,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
+import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
@@ -118,25 +119,34 @@
return bindingId;
}
- @Override
- public W3CEndpointReference createW3CEndpointReference(String address, QName
serviceName, QName portName, List<Element> metadata, String wsdlDocumentLocation,
- List<Element> referenceParameters)
+ public W3CEndpointReference createW3CEndpointReference(final String address, final
QName interfaceName,
+ final QName serviceName, final QName portName, final List<Element>
metadata, final String wsdlDocumentLocation,
+ final List<Element> referenceParameters, final List<Element>
elements, final Map<QName, String> attributes)
{
if ((serviceName == null) && (address == null) && (portName ==
null))
throw new IllegalStateException();
if ((portName != null) && (serviceName == null))
throw new IllegalStateException();
-
- NativeEndpointReference epr = new NativeEndpointReference();
+
+ final NativeEndpointReference epr = new NativeEndpointReference();
epr.setAddress(address);
epr.setServiceName(serviceName);
epr.setEndpointName(portName);
+ epr.setInterfaceName(interfaceName);
epr.setMetadata(metadata);
epr.setWsdlLocation(wsdlDocumentLocation);
epr.setReferenceParameters(referenceParameters);
+
return EndpointReferenceUtil.transform(W3CEndpointReference.class, epr);
}
+ public W3CEndpointReference createW3CEndpointReference(final String address, final
QName serviceName,
+ final QName portName, final List<Element> metadata, final String
wsdlDocumentLocation,
+ final List<Element> referenceParameters)
+ {
+ return createW3CEndpointReference(address, null, serviceName, portName, metadata,
wsdlDocumentLocation, referenceParameters, null, null);
+ }
+
@Override
public <T> T getPort(EndpointReference epr, Class<T> sei,
WebServiceFeature... features)
{
@@ -157,8 +167,9 @@
throw new NullPointerException("Provided eprInfoset cannot be null");
try
{
- //we currently support W3CEndpointReference only
- return new W3CEndpointReference(eprInfoset);
+ final NativeEndpointReference nativeEPR = new
NativeEndpointReference(eprInfoset);
+ final Source source =
EndpointReferenceUtil.getSourceFromEndpointReference(nativeEPR);
+ return new W3CEndpointReference(source);
}
catch (Exception e)
{
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/EndpointReferenceUtil.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/EndpointReferenceUtil.java 2012-04-20
15:05:19 UTC (rev 16205)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/EndpointReferenceUtil.java 2012-04-24
06:33:29 UTC (rev 16206)
@@ -68,7 +68,7 @@
throw new WebServiceException("EndpointReference of type " + clazz +
" not supported.");
}
- private static Source getSourceFromEndpointReference(EndpointReference epr)
+ public static Source getSourceFromEndpointReference(EndpointReference epr)
{
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
StreamResult result = new StreamResult(outputStream);
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/NativeEndpointReference.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/NativeEndpointReference.java 2012-04-20
15:05:19 UTC (rev 16205)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/jaxws/wsaddressing/NativeEndpointReference.java 2012-04-24
06:33:29 UTC (rev 16206)
@@ -23,8 +23,11 @@
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.ResourceBundle;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
@@ -41,7 +44,7 @@
import javax.xml.transform.Source;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.WebServiceException;
-
+import org.jboss.wsf.common.DOMUtils;
import org.w3c.dom.Element;
/**
@@ -53,35 +56,40 @@
* @see EndpointReferenceUtil class.
*
* @author alessio.soldano(a)jboss.com
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
* @since 28-Feb-2009
- *
*/
-
-// XmlRootElement allows this class to be marshalled on its own
-@XmlRootElement(name = "EndpointReference", namespace =
NativeEndpointReference.NS)
-@XmlType(name = "EndpointReferenceType", namespace =
NativeEndpointReference.NS)
+@XmlRootElement(name = "EndpointReference", namespace =
NativeEndpointReference.WSA_NS)
+@XmlType(name = "EndpointReferenceType", namespace =
NativeEndpointReference.WSA_NS)
public final class NativeEndpointReference extends EndpointReference
{
- protected static final String NS = "http://www.w3.org/2005/08/addressing";
+ 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(WSDLI_NS,
"wsdlLocation", "wsdli");
+ private static final String ENDPOINT_ATTRIBUTE = "EndpointName";
+ private static final JAXBContext jc = getJaxbContext();
- private final static JAXBContext jc = getJaxbContext();
-
// private but necessary properties for databinding
- @XmlElement(name = "Address", namespace = NS)
+ @XmlElement(name = "Address", namespace = WSA_NS)
private Address address;
- @XmlElement(name = "ReferenceParameters", namespace = NS)
+ @XmlElement(name = "ReferenceParameters", namespace = WSA_NS)
private Elements referenceParameters;
- @XmlElement(name = "Metadata", namespace = NS)
+ @XmlElement(name = "Metadata", namespace = WSA_NS)
private Elements metadata;
@XmlAnyAttribute
- Map<QName, String> attributes;
+ private Map<QName, String> attributes;
@XmlAnyElement
- List<Element> elements;
+ private List<Element> elements;
// not marshalled
private QName serviceName;
+ private Element serviceNameElement;
private QName endpointName;
- private URL wsdlLocation;
+ private QName interfaceName;
+ private String wsdlLocation;
public NativeEndpointReference()
{
@@ -106,16 +114,67 @@
{
NativeEndpointReference epr = jc.createUnmarshaller().unmarshal(source,
NativeEndpointReference.class).getValue();
this.address = epr.address;
- this.metadata = epr.metadata;
- this.referenceParameters = epr.referenceParameters;
+ if ((epr.referenceParameters != null) &&
(!epr.referenceParameters.isEmpty()))
+ {
+ this.referenceParameters = epr.referenceParameters;
+ }
+ if ((epr.metadata != null) && (!epr.metadata.isEmpty()))
+ {
+ this.metadata = epr.metadata;
+ }
+ this.attributes = epr.attributes;
+ this.elements = epr.elements;
+ if (epr.metadata != null)
+ {
+ Map<QName, String> metadataAttributes = epr.metadata.getAttributes();
+ if (metadataAttributes != null)
+ {
+ final String wsdlLocation = metadataAttributes.get(WSDL_LOCATION_QNAME);
+ if (wsdlLocation != null)
+ {
+ 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();
+ if (metadataElements != null)
+ {
+ for (Element e : epr.metadata.getElements())
+ {
+ if (WSAM_NS.equals(e.getNamespaceURI()))
+ {
+ if (e.getLocalName().equals(SERVICE_QNAME.getLocalPart()))
+ {
+ this.serviceName = this.getQName(e, e.getTextContent());
+ String endpointName = e.getAttribute(ENDPOINT_ATTRIBUTE);
+ if (endpointName != null)
+ {
+ this.endpointName = new QName(
+ this.serviceName.getNamespaceURI(),
+ endpointName,
+ this.serviceName.getPrefix()
+ );
+ }
+ }
+ if (e.getLocalName().equals(INTERFACE_QNAME.getLocalPart()))
+ {
+ this.interfaceName = this.getQName(e, e.getTextContent());
+ }
+ }
+ }
+ }
+ }
}
catch (JAXBException e)
{
- throw new WebServiceException("Error unmarshalling NativeEndpointReference
", e);
+ throw new WebServiceException("Error unmarshalling
NativeEndpointReference", e);
}
catch (ClassCastException e)
{
- throw new WebServiceException("Source did not contain
NativeEndpointReference", e);
+ throw new WebServiceException("Source did not contain
NativeEndpointReference", e);
}
}
@@ -127,6 +186,9 @@
public void setAddress(String address)
{
+ if (address == null)
+ return;
+
this.address = new Address(address);
}
@@ -136,9 +198,20 @@
return serviceName;
}
- public void setServiceName(QName serviceName)
+ public void setServiceName(final QName serviceName)
{
+ if (serviceName == null)
+ return;
+
this.serviceName = serviceName;
+ this.serviceNameElement = DOMUtils.createElement(SERVICE_QNAME);
+ final String attrName = this.getNamespaceAttributeName(serviceName.getPrefix());
+ this.serviceNameElement.setAttribute(attrName, serviceName.getNamespaceURI());
+ this.serviceNameElement.setTextContent(this.toString(serviceName));
+ if (this.metadata == null)
+ this.metadata = new Elements();
+
+ this.metadata.addElement(this.serviceNameElement);
}
@XmlTransient
@@ -149,47 +222,99 @@
public void setEndpointName(QName endpointName)
{
+ if (endpointName == null)
+ return;
+
this.endpointName = endpointName;
}
@XmlTransient
+ public QName getInterfaceName()
+ {
+ return interfaceName;
+ }
+
+ public void setInterfaceName(final QName interfaceName)
+ {
+ if (interfaceName == null)
+ return;
+
+ this.interfaceName = interfaceName;
+ Element interfaceNameElement = DOMUtils.createElement(INTERFACE_QNAME);
+ final String attrName = this.getNamespaceAttributeName(interfaceName.getPrefix());
+ interfaceNameElement.setAttribute(attrName, interfaceName.getNamespaceURI());
+ interfaceNameElement.setTextContent(this.toString(interfaceName));
+ if (this.metadata == null)
+ this.metadata = new Elements();
+
+ this.metadata.addElement(interfaceNameElement);
+ }
+
+ @XmlTransient
public List<Element> getMetadata()
{
- return metadata != null ? metadata.getElements() : null;
+ if (this.metadata == null)
+ return null;
+
+ return this.metadata.getElements();
}
public void setMetadata(List<Element> metadata)
{
- this.metadata = new Elements(metadata);
+ if ((metadata == null) || (metadata.size() == 0))
+ return;
+
+ if (this.metadata == null)
+ this.metadata = new Elements();
+
+ this.metadata.setElements(metadata);
}
@XmlTransient
public URL getWsdlLocation()
{
- return wsdlLocation;
- }
-
- public void setWsdlLocation(String wsdlLocation)
- {
- try
+ if (this.wsdlLocation != null)
{
- this.wsdlLocation = wsdlLocation != null ? new URL(wsdlLocation) : null;
+ return this.toURL(this.wsdlLocation);
}
- catch (MalformedURLException e)
+ else
{
- throw new IllegalArgumentException("Invalid URL: " + wsdlLocation);
+ String address = this.getAddress();
+ if (address != null)
+ {
+ return this.toURL(address + "?wsdl");
+ }
}
+
+ return null;
}
+
+ public void setWsdlLocation(String wsdlLocation)
+ {
+ if (wsdlLocation == null)
+ return;
+
+ this.wsdlLocation = wsdlLocation;
+ }
@XmlTransient
public List<Element> getReferenceParameters()
{
- return referenceParameters != null ? referenceParameters.getElements() : null;
+ if (this.referenceParameters == null)
+ return null;
+
+ return this.referenceParameters.getElements();
}
public void setReferenceParameters(List<Element> metadata)
{
- this.referenceParameters = new Elements(metadata);
+ if ((metadata == null) || (metadata.size() == 0))
+ return;
+
+ if (this.referenceParameters == null)
+ this.referenceParameters = new Elements();
+
+ this.referenceParameters.setElements(metadata);
}
/**
@@ -218,6 +343,31 @@
*/
public void writeTo(Result result)
{
+ if (this.endpointName != null && this.serviceNameElement != null)
+ {
+ this.serviceNameElement.setAttribute(ENDPOINT_ATTRIBUTE,
this.endpointName.getLocalPart());
+
+ 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
{
Marshaller marshaller = jc.createMarshaller();
@@ -226,10 +376,22 @@
}
catch (JAXBException e)
{
- throw new WebServiceException("Error marshalling NativeEndpointReference.
", e);
+ throw new WebServiceException("Error marshalling
NativeEndpointReference", e);
}
}
+ private URL toURL(final String s)
+ {
+ try
+ {
+ return new URL(s);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException(e.getMessage(), e);
+ }
+ }
+
private static JAXBContext getJaxbContext()
{
try
@@ -238,10 +400,50 @@
}
catch (JAXBException ex)
{
- throw new WebServiceException("Cannot obtain JAXB context", ex);
+ throw new WebServiceException("=Cannot obtain JAXB context", ex);
}
}
+ private String toString(final QName qname)
+ {
+ StringBuilder sb = new StringBuilder();
+ if (qname.getPrefix() != null && qname.getPrefix().length() > 0)
+ {
+ sb.append(qname.getPrefix());
+ sb.append(':');
+ }
+ sb.append(qname.getLocalPart());
+ return sb.toString();
+ }
+
+ 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)
+ {
+ final String namespace = e.getAttribute("xmlns");
+ return new QName(namespace, nodeValue);
+ }
+ else
+ {
+ final String prefix = nodeValue.substring(0, separatorIndex);
+ final String localPart = nodeValue.substring(separatorIndex + 1);
+ final String namespace = e.lookupNamespaceURI(prefix);
+ return new QName(namespace, localPart, prefix);
+ }
+ }
+
+ private String getNamespaceAttributeName(final String prefix)
+ {
+ if (prefix == null || "".equals(prefix))
+ return "xmlns";
+
+ return "xmlns:" + prefix;
+ }
+
private static class Address
{
@XmlValue
@@ -305,8 +507,24 @@
public void setElements(List<Element> elements)
{
- this.elements = elements;
+ if (this.elements == null)
+ {
+ this.elements = elements;
+ }
+ else
+ {
+ this.elements.addAll(elements);
+ }
}
+
+ public void addElement(Element e)
+ {
+ if (this.elements == null)
+ {
+ this.elements = new LinkedList<Element>();
+ }
+ this.elements.add(e);
+ }
@XmlTransient
public Map<QName, String> getAttributes()
@@ -316,7 +534,33 @@
public void setAttributes(Map<QName, String> attributes)
{
- this.attributes = attributes;
+ if (this.attributes == null)
+ {
+ this.attributes = attributes;
+ }
+ else
+ {
+ this.attributes.putAll(attributes);
+ }
}
+
+ public void addAttribute(QName attrName, String attrValue)
+ {
+ if (this.attributes == null)
+ {
+ this.attributes = new HashMap<QName, String>();
+ }
+ this.attributes.put(attrName, attrValue);
+ }
+
+ @XmlTransient
+ public boolean isEmpty()
+ {
+ final boolean noAttributes = this.attributes == null || this.attributes.size()
== 0;
+ final boolean noElements = this.elements == null || this.elements.size() == 0;
+
+ return noAttributes && noElements;
+ }
}
-}
+
+}
\ No newline at end of file
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/epr/NativeEndpointReferenceTestCase.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/epr/NativeEndpointReferenceTestCase.java
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/epr/NativeEndpointReferenceTestCase.java 2012-04-24
06:33:29 UTC (rev 16206)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.epr;
+
+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.core.jaxws.wsaddressing.NativeEndpointReference;
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.test.JBossWSTest;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Tests NativeEndpointReference de/serializations.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class NativeEndpointReferenceTestCase extends JBossWSTest
+{
+ private static final String URL = "http://localhost:8080/hello";
+ private static final String WSDL_URL = URL + "?wsdl";
+ private static final String MY_NS = "http://helloservice.org/wsdl";
+ private 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 WSAM_PREFIX = "wsam";
+ private static final String MY_PREFIX = "myns";
+ private static final QName PARAM1_QNAME = new
QName("http://helloservice.org/param1", "param1", "ns1");
+ private static final QName PARAM2_QNAME = new
QName("http://helloservice.org/param2", "param2", "ns2");
+ private static final QName WSAM_SERVICE_QNAME = new QName(WSAM_NS,
"ServiceName");
+ private static final QName WSAM_INTERFACE_QNAME = new QName(WSAM_NS,
"InterfaceName");
+ private static final QName METADATA_QNAME = new QName(WSA_NS, "Metadata");
+ private static final String XML =
+ "<EndpointReference
xmlns='http://www.w3.org/2005/08/addressing'> " +
+ " <Address>http://localhost:8080/hello</Address>" +
+ " <ReferenceParameters>" +
+ " <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
wsdli:wsdlLocation='http://helloservice.org/wsdl
http://localhost:8080/hello?wsdl'
xmlns:wsdli='http://www.w3.org/ns/wsdl-instance'>" +
+ " <wsam:ServiceName EndpointName='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>" +
+ "</EndpointReference>";
+
+ public void testNativeEndpointReferenceFromSource() throws Exception
+ {
+ final Source xml = new DOMSource(DOMUtils.parse(XML));
+ NativeEndpointReference epr = new NativeEndpointReference(xml);
+ DOMResult dr = new DOMResult();
+ epr.writeTo(dr);
+ Node endpointReferenceElement = dr.getNode();
+ 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)
+ {
+ Element e = (Element)DOMUtils.getFirstChildElement(root, nodeName, true);
+ assertNotNull("Reference parameter " + nodeName + " not found",
e);
+ String actual = DOMUtils.getTextContent(e);
+ if ((actual == null) || (!actual.equals(refParamValue)))
+ {
+ fail("Reference parameter " + nodeName + " expected value is
" + refParamValue);
+ }
+ }
+
+ private static void assertMetaData(final Node root)
+ {
+ Element metadataElement = (Element)DOMUtils.getFirstChildElement(root,
METADATA_QNAME, true);
+ 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));
+ String endpointNameValue = DOMUtils.getAttributeValue(serviceNameElement,
"EndpointName");
+ assertNotNull("cannot find endpointName attribute value",
endpointNameValue);
+ assertEquals("wrong endpointName attribute value", endpointNameValue,
"HelloPort");
+ Element interfaceNameElement =
(Element)DOMUtils.getFirstChildElement(metadataElement, WSAM_INTERFACE_QNAME);
+ assertNamespaces(interfaceNameElement);
+ assertEquals("wrong text content in InterfaceName element",
"myns:Hello", DOMUtils.getTextContent(interfaceNameElement));
+ }
+
+ private static void assertNamespaces(final Element e)
+ {
+ String myNamespace = e.lookupNamespaceURI(MY_PREFIX);
+ assertNotNull("namespace is null for prefix " + MY_PREFIX + ", are
you using our patched xalan?", myNamespace);
+ assertEquals("namespace mismatch", myNamespace, MY_NS);
+ String wsamNamespace = e.lookupNamespaceURI(WSAM_PREFIX);
+ assertNotNull("namespace is null for prefix " + WSAM_PREFIX + ", are
you using our patched xalan?", wsamNamespace);
+ assertEquals("namespace mismatch", wsamNamespace, WSAM_NS);
+ }
+}