[jboss-svn-commits] JBL Code SVN: r38203 - in labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src: test/java/org/jboss/soa/esb/actions/soap and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Sep 26 23:32:22 EDT 2012
Author: tcunning
Date: 2012-09-26 23:32:21 -0400 (Wed, 26 Sep 2012)
New Revision: 38203
Added:
labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-cxf.wsdl
labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-https.wsdl
labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-prefixed.wsdl
Modified:
labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java
labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java
labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int.wsdl
Log:
JBESB-3802
Check in Tadayoshi's fix for wsdl definitions defined with a namespace prefix.
Modified: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java 2012-09-26 09:58:07 UTC (rev 38202)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java 2012-09-27 03:32:21 UTC (rev 38203)
@@ -85,12 +85,12 @@
Document doc = dBuilder.parse(is);
doc.getDocumentElement().normalize();
-
- NodeList nList = doc.getElementsByTagName("service");
+
+ NodeList nList = doc.getDocumentElement().getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node nNode = nList.item(i);
- if (nNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (nNode.getNodeType() == Node.ELEMENT_NODE && Constants.ELEM_SERVICE.equals(getLocalPart(nNode))) {
Element eElement = (Element) nNode;
getPort(eElement);
}
@@ -112,12 +112,12 @@
Document doc = dBuilder.parse(is);
doc.getDocumentElement().normalize();
-
- NodeList nList = doc.getElementsByTagName(Constants.ELEM_TYPES);
+
+ NodeList nList = doc.getDocumentElement().getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node nNode = nList.item(i);
- if (nNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (nNode.getNodeType() == Node.ELEMENT_NODE && Constants.ELEM_TYPES.equals(getLocalPart(nNode))) {
Element eElement = (Element) nNode;
getSchema(eElement);
}
@@ -188,12 +188,13 @@
Element child = (Element) node;
if (IMPORT_ELEM.equals(getLocalPart(node))) {
-
+
if (child.hasAttribute(SCHEMA_LOCATION_ATTR)) {
- if ((child.getAttribute(SCHEMA_LOCATION_ATTR) != null)
- && (child.getAttribute(SCHEMA_LOCATION_ATTR).startsWith("http://"))) {
- String xsdLocation = deployXSD(child.getAttribute(SCHEMA_LOCATION_ATTR));
- child.setAttribute(SCHEMA_LOCATION_ATTR, xsdLocation);
+ String schemaLocation = child.getAttribute(SCHEMA_LOCATION_ATTR);
+ if (schemaLocation != null
+ && (schemaLocation.startsWith("http://") || schemaLocation.startsWith("https://"))) {
+ String rewrittenLocation = deployXSD(schemaLocation);
+ child.setAttribute(SCHEMA_LOCATION_ATTR, rewrittenLocation);
}
}
}
Modified: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java 2012-09-26 09:58:07 UTC (rev 38202)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java 2012-09-27 03:32:21 UTC (rev 38203)
@@ -27,23 +27,19 @@
import java.net.URL;
import java.util.Map;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-
import junit.framework.TestCase;
import org.jboss.soa.esb.actions.soap.SchemaDeployer;
import org.jboss.soa.esb.actions.soap.SchemaDeployerImpl;
import org.jboss.soa.esb.actions.soap.SchemaLocationParser;
-import org.xml.sax.SAXException;
+import org.jboss.soa.esb.util.XPathUtil;
public class SchemaLocatorUnitTest extends TestCase {
public SchemaLocatorUnitTest() {
}
- public void testSchemaLocationExternal()
- throws ParserConfigurationException, SAXException, IOException, TransformerException {
+ public void testSchemaLocationExternal() throws Exception {
StringBuffer fileData = getFileData("/test-schema-ext.wsdl");
@@ -53,6 +49,9 @@
String data = slp.parse(fileData.toString());
assertEquals(slp.getSoapAddress(), "http://localhost:8080/jaxws-jbws2526");
+ assertEquals(
+ "http://localhost:8080/jaxws-jbws2526?wsdl&resource=jbws2526.xsd",
+ XPathUtil.getNodeFromXPathExpression(data, "/definitions/types/schema/import").getAttribute("schemaLocation"));
Map<String, String> resources = sd.getResources();
assertEquals(1, resources.size());
@@ -75,13 +74,82 @@
SchemaLocationParser slp = new SchemaLocationParser(sd);
String data = slp.parse(fileData.toString());
- assertEquals(slp.getSoapAddress(), "http://127.0.0.1:8080/Quickstart_HelloWorldWS/HelloWorldWS");
+ assertEquals(slp.getSoapAddress(), "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS");
+ assertEquals(
+ "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ XPathUtil.getNodeFromXPathExpression(data, "/definitions/types/schema/import").getAttribute("schemaLocation"));
Map<String, String> resources = sd.getResources();
assertEquals(1, resources.size());
assertEquals("!!! Dummy XSD data !!!", resources.get("HelloWorldService.xsd"));
}
+
+ public void testSchemaLocationInternal_cxf() throws Exception {
+ StringBuffer fileData = getFileData("/test-schema-int-cxf.wsdl");
+ SchemaDeployer sd = new SchemaDeployerImpl() {
+ // mock method to eschew actual network access
+ @Override
+ public String getXSDString(URL url, File tempFile) throws IOException {
+ return "!!! Dummy XSD data !!!";
+ }
+ };
+ SchemaLocationParser slp = new SchemaLocationParser(sd);
+ String data = slp.parse(fileData.toString());
+ assertEquals(slp.getSoapAddress(), "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS");
+ assertEquals(
+ "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ XPathUtil.getNodeFromXPathExpression(data, "/definitions/types/schema/import").getAttribute("schemaLocation"));
+
+ Map<String, String> resources = sd.getResources();
+ assertEquals(1, resources.size());
+ assertEquals("!!! Dummy XSD data !!!", resources.get("HelloWorldService.xsd"));
+ }
+
+ public void testSchemaLocationInternal_wsdlPrefixed() throws Exception {
+ StringBuffer fileData = getFileData("/test-schema-int-prefixed.wsdl");
+ SchemaDeployer sd = new SchemaDeployerImpl() {
+ // mock method to eschew actual network access
+ @Override
+ public String getXSDString(URL url, File tempFile) throws IOException {
+ return "!!! Dummy XSD data !!!";
+ }
+ };
+ SchemaLocationParser slp = new SchemaLocationParser(sd);
+ String data = slp.parse(fileData.toString());
+
+ assertEquals(slp.getSoapAddress(), "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS");
+ assertEquals(
+ "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ XPathUtil.getNodeFromXPathExpression(data, "/definitions/types/schema/import").getAttribute("schemaLocation"));
+
+ Map<String, String> resources = sd.getResources();
+ assertEquals(1, resources.size());
+ assertEquals("!!! Dummy XSD data !!!", resources.get("HelloWorldService.xsd"));
+ }
+
+ public void testSchemaLocationInternal_https() throws Exception {
+ StringBuffer fileData = getFileData("/test-schema-int-https.wsdl");
+ SchemaDeployer sd = new SchemaDeployerImpl() {
+ // mock method to eschew actual network access
+ @Override
+ public String getXSDString(URL url, File tempFile) throws IOException {
+ return "!!! Dummy XSD data !!!";
+ }
+ };
+ SchemaLocationParser slp = new SchemaLocationParser(sd);
+ String data = slp.parse(fileData.toString());
+
+ assertEquals(slp.getSoapAddress(), "https://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS");
+ assertEquals(
+ "https://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ XPathUtil.getNodeFromXPathExpression(data, "/definitions/types/schema/import").getAttribute("schemaLocation"));
+
+ Map<String, String> resources = sd.getResources();
+ assertEquals(1, resources.size());
+ assertEquals("!!! Dummy XSD data !!!", resources.get("HelloWorldService.xsd"));
+ }
+
private StringBuffer getFileData(String filePath) throws FileNotFoundException,
IOException {
StringBuffer fileData = new StringBuffer(1000);
Added: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-cxf.wsdl
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-cxf.wsdl (rev 0)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-cxf.wsdl 2012-09-27 03:32:21 UTC (rev 38203)
@@ -0,0 +1,36 @@
+<definitions name='HelloWorldServiceService' targetNamespace='http://webservice_producer/helloworld' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://webservice_producer/helloworld' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <types>
+ <xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <xsd:import namespace='http://webservice_producer/helloworld' schemaLocation='http://127.0.0.1:8080/HelloWorld_WS/HelloWorldWS?xsd=HelloWorldService.xsd'/>
+ </xsd:schema>
+ </types>
+ <message name='HelloWorldWS_sayHelloResponse'>
+ <part element='tns:sayHelloResponse' name='sayHelloResponse'></part>
+ </message>
+ <message name='HelloWorldWS_sayHello'>
+ <part element='tns:sayHello' name='sayHello'></part>
+ </message>
+ <portType name='HelloWorldWS'>
+ <operation name='sayHello' parameterOrder='sayHello'>
+ <input message='tns:HelloWorldWS_sayHello'></input>
+ <output message='tns:HelloWorldWS_sayHelloResponse'></output>
+ </operation>
+ </portType>
+ <binding name='HelloWorldWSBinding' type='tns:HelloWorldWS'>
+ <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='sayHello'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body use='literal'/>
+ </input>
+ <output>
+ <soap:body use='literal'/>
+ </output>
+ </operation>
+ </binding>
+ <service name='HelloWorldServiceService'>
+ <port binding='tns:HelloWorldWSBinding' name='HelloWorldWSPort'>
+ <soap:address location='http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS'/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Added: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-https.wsdl
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-https.wsdl (rev 0)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-https.wsdl 2012-09-27 03:32:21 UTC (rev 38203)
@@ -0,0 +1,36 @@
+<definitions name='HelloWorldServiceService' targetNamespace='http://webservice_producer/helloworld' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://webservice_producer/helloworld' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <types>
+ <xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <xsd:import namespace='http://webservice_producer/helloworld' schemaLocation='https://127.0.0.1:8080/HelloWorld_WS/HelloWorldWS?wsdl&resource=HelloWorldService.xsd'/>
+ </xsd:schema>
+ </types>
+ <message name='HelloWorldWS_sayHelloResponse'>
+ <part element='tns:sayHelloResponse' name='sayHelloResponse'></part>
+ </message>
+ <message name='HelloWorldWS_sayHello'>
+ <part element='tns:sayHello' name='sayHello'></part>
+ </message>
+ <portType name='HelloWorldWS'>
+ <operation name='sayHello' parameterOrder='sayHello'>
+ <input message='tns:HelloWorldWS_sayHello'></input>
+ <output message='tns:HelloWorldWS_sayHelloResponse'></output>
+ </operation>
+ </portType>
+ <binding name='HelloWorldWSBinding' type='tns:HelloWorldWS'>
+ <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='sayHello'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body use='literal'/>
+ </input>
+ <output>
+ <soap:body use='literal'/>
+ </output>
+ </operation>
+ </binding>
+ <service name='HelloWorldServiceService'>
+ <port binding='tns:HelloWorldWSBinding' name='HelloWorldWSPort'>
+ <soap:address location='https://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS'/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Added: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-prefixed.wsdl
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-prefixed.wsdl (rev 0)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int-prefixed.wsdl 2012-09-27 03:32:21 UTC (rev 38203)
@@ -0,0 +1,36 @@
+<wsdl:definitions name='HelloWorldServiceService' targetNamespace='http://webservice_producer/helloworld' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://webservice_producer/helloworld' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <wsdl:types>
+ <xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <xsd:import namespace='http://webservice_producer/helloworld' schemaLocation='http://127.0.0.1:8080/HelloWorld_WS/HelloWorldWS?wsdl&resource=HelloWorldService.xsd'/>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name='HelloWorldWS_sayHelloResponse'>
+ <wsdl:part element='tns:sayHelloResponse' name='sayHelloResponse'></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name='HelloWorldWS_sayHello'>
+ <wsdl:part element='tns:sayHello' name='sayHello'></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name='HelloWorldWS'>
+ <wsdl:operation name='sayHello' parameterOrder='sayHello'>
+ <wsdl:input message='tns:HelloWorldWS_sayHello'></wsdl:input>
+ <wsdl:output message='tns:HelloWorldWS_sayHelloResponse'></wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name='HelloWorldWSBinding' type='tns:HelloWorldWS'>
+ <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
+ <wsdl:operation name='sayHello'>
+ <soap:operation soapAction=''/>
+ <wsdl:input>
+ <soap:body use='literal'/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use='literal'/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name='HelloWorldServiceService'>
+ <wsdl:port binding='tns:HelloWorldWSBinding' name='HelloWorldWSPort'>
+ <soap:address location='http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS'/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file
Modified: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int.wsdl
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int.wsdl 2012-09-26 09:58:07 UTC (rev 38202)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int.wsdl 2012-09-27 03:32:21 UTC (rev 38203)
@@ -1,7 +1,7 @@
<definitions name='HelloWorldServiceService' targetNamespace='http://webservice_producer/helloworld' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://webservice_producer/helloworld' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<types>
<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
- <xsd:import namespace='http://webservice_producer/helloworld' schemaLocation='http://127.0.0.1:8080/Quickstart_HelloWorldWS/HelloWorldWS?wsdl&resource=HelloWorldService.xsd'/>
+ <xsd:import namespace='http://webservice_producer/helloworld' schemaLocation='http://127.0.0.1:8080/HelloWorld_WS/HelloWorldWS?wsdl&resource=HelloWorldService.xsd'/>
</xsd:schema>
</types>
<message name='HelloWorldWS_sayHelloResponse'>
@@ -30,7 +30,7 @@
</binding>
<service name='HelloWorldServiceService'>
<port binding='tns:HelloWorldWSBinding' name='HelloWorldWSPort'>
- <soap:address location='http://127.0.0.1:8080/Quickstart_HelloWorldWS/HelloWorldWS'/>
+ <soap:address location='http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS'/>
</port>
</service>
</definitions>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list