Author: mmusaji
Date: 2013-03-04 04:19:04 -0500 (Mon, 04 Mar 2013)
New Revision: 17377
Modified:
common/branches/jbossws-common-2.0.4.GA_BZ-916944/
common/branches/jbossws-common-2.0.4.GA_BZ-916944/src/main/java/org/jboss/ws/common/deployment/SOAPAddressWSDLParser.java
Log:
[BZ916944] Commit -r 17050 from JBWS-3571
Property changes on: common/branches/jbossws-common-2.0.4.GA_BZ-916944
___________________________________________________________________
Modified: svn:mergeinfo
- /common/branches/asoldano:14028-14056
/common/trunk:16016
+ /common/branches/asoldano:14028-14056
/common/trunk:16016,17050
Modified:
common/branches/jbossws-common-2.0.4.GA_BZ-916944/src/main/java/org/jboss/ws/common/deployment/SOAPAddressWSDLParser.java
===================================================================
---
common/branches/jbossws-common-2.0.4.GA_BZ-916944/src/main/java/org/jboss/ws/common/deployment/SOAPAddressWSDLParser.java 2013-03-01
15:36:36 UTC (rev 17376)
+++
common/branches/jbossws-common-2.0.4.GA_BZ-916944/src/main/java/org/jboss/ws/common/deployment/SOAPAddressWSDLParser.java 2013-03-04
09:19:04 UTC (rev 17377)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, 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.
*
@@ -29,10 +29,13 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.ResourceBundle;
+import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamConstants;
@@ -52,6 +55,7 @@
{
private static final ResourceBundle bundle =
BundleUtils.getBundle(SOAPAddressWSDLParser.class);
public static final String SOAP_OVER_JMS_NS =
"http://www.w3.org/2010/soapjms/";
+ public static final String SOAP_HTTP_NS =
"http://schemas.xmlsoap.org/soap/http";
private static final String WSDL_NS = "http://schemas.xmlsoap.org/wsdl/";
private static final String SOAP_NS =
"http://schemas.xmlsoap.org/wsdl/soap/";
private static final String SOAP12_NS =
"http://schemas.xmlsoap.org/wsdl/soap12/";
@@ -59,6 +63,7 @@
private static final String SERVICE = "service";
private static final String PORT = "port";
private static final String BINDING = "binding";
+ private static final String IMPORT = "import";
private static final String TRANSPORT = "transport";
private static final String ADDRESS = "address";
private static final String LOCATION = "location";
@@ -69,12 +74,22 @@
public SOAPAddressWSDLParser(URL wsdlUrl)
{
- this.metadata = getMetaData(wsdlUrl);
+ this.metadata = new WSDLMetaData();
+ parse(this.metadata, wsdlUrl);
+ Map<String, Boolean> map = this.metadata.getImports();
+ while (!map.isEmpty() && map.containsValue(false)) {
+ Set<String> imports = new HashSet<String>(map.keySet());
+ for (String i : imports) {
+ if (!map.get(i)) {
+ parse(this.metadata, i);
+ map.put(i, true);
+ }
+ }
+ }
}
- public String filterSoapAddress(QName serviceName, QName portName, String
transportNamespace)
+ public String filterSoapAddress(QName serviceName, QName portName, String[]
transportNamespaces)
{
- //get the soap:address of the required service/port if the corresponding binding
uses SOAP over JMS transport
WSDLServiceMetaData smd = metadata.getServices().get(serviceName);
if (smd != null)
{
@@ -82,23 +97,46 @@
if (pmd != null)
{
WSDLBindingMetaData bmd = metadata.getBindings().get(pmd.getBindingName());
- if (bmd != null &&
transportNamespace.equals(bmd.getSoapTransport()))
+ if (bmd != null)
{
- return pmd.getSoapAddress();
+ for (String txNs : transportNamespaces)
+ {
+ if (txNs.equals(bmd.getSoapTransport()))
+ {
+ return pmd.getSoapAddress();
+ }
+ }
}
}
}
return null;
}
- protected static WSDLMetaData getMetaData(URL wsdlUrl)
+ public String filterSoapAddress(QName serviceName, QName portName, String
transportNamespace)
{
+ return filterSoapAddress(serviceName, portName, new String[]{transportNamespace});
+ }
+
+ protected static void parse(WSDLMetaData metadata, String wsdlUrl)
+ {
+ try
+ {
+ parse(metadata, new URL(wsdlUrl));
+ }
+ catch (MalformedURLException e)
+ {
+ throw new WebServiceException(BundleUtils.getMessage(bundle,
"FAILED_TO_READ", new Object[]{ wsdlUrl , e.getMessage()}), e);
+ }
+ }
+
+ protected static void parse(WSDLMetaData metadata, URL wsdlUrl)
+ {
InputStream is = null;
try
{
is = wsdlUrl.openStream();
XMLStreamReader xmlr = StAXUtils.createXMLStreamReader(is);
- return getMetaData(xmlr);
+ parse(metadata, xmlr, wsdlUrl);
}
catch (Exception e)
{
@@ -114,7 +152,7 @@
}
}
- private static WSDLMetaData getMetaData(XMLStreamReader reader) throws
XMLStreamException
+ private static void parse(WSDLMetaData metadata, XMLStreamReader reader, URL wsdlUrl)
throws XMLStreamException
{
int iterate;
try
@@ -126,7 +164,6 @@
// skip non-tag elements
iterate = reader.nextTag();
}
- WSDLMetaData metadata = new WSDLMetaData();
switch (iterate)
{
case END_ELEMENT : {
@@ -138,7 +175,7 @@
if (match(reader, WSDL_NS, DEFINITIONS))
{
String targetNS = reader.getAttributeValue(null, TARGET_NAMESPACE);
- parseDefinitions(reader, metadata, targetNS);
+ parseDefinitions(reader, metadata, targetNS, wsdlUrl);
}
else
{
@@ -146,10 +183,9 @@
}
}
}
- return metadata;
}
- private static void parseDefinitions(XMLStreamReader reader, WSDLMetaData metadata,
String targetNS) throws XMLStreamException
+ private static void parseDefinitions(XMLStreamReader reader, WSDLMetaData metadata,
String targetNS, URL wsdlUrl) throws XMLStreamException
{
while (reader.hasNext())
{
@@ -175,6 +211,14 @@
bmd.setName(name);
metadata.getBindings().put(bmd.getName(), bmd);
}
+ else if (match(reader, WSDL_NS, IMPORT)) {
+ final String location = reader.getAttributeValue(null, LOCATION);
+ final String url = wsdlUrl.toString();
+ final String newUrl = url.substring(0, url.lastIndexOf("/") +
(location.startsWith("/") ? 0 : 1)) + location;
+ if (!metadata.getImports().containsKey(newUrl)) {
+ metadata.getImports().put(newUrl, false);
+ }
+ }
continue;
}
}
@@ -270,6 +314,7 @@
{
private Map<QName, WSDLServiceMetaData> services = new HashMap<QName,
SOAPAddressWSDLParser.WSDLServiceMetaData>();
private Map<QName, WSDLBindingMetaData> bindings = new HashMap<QName,
SOAPAddressWSDLParser.WSDLBindingMetaData>();
+ private Map<String, Boolean> imports = new HashMap<String, Boolean>();
//<url, processed>
public Map<QName, WSDLServiceMetaData> getServices()
{
@@ -279,6 +324,11 @@
{
return bindings;
}
+
+ public Map<String, Boolean> getImports()
+ {
+ return imports;
+ }
}
private static class WSDLServiceMetaData