Fix a bug with WSDL import for files generated by IIS (.NET)
diff --git a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/helpers/UriAndUrlHelper.java b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/helpers/UriAndUrlHelper.java
index 36592b7..62da2d9 100644
--- a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/helpers/UriAndUrlHelper.java
+++ b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/helpers/UriAndUrlHelper.java
@@ -97,10 +97,20 @@
fileName = fileName.substring( ++ index );
// Handle cases like "jsp?value="
- if( fileName.toLowerCase().endsWith( "?wsdl" )) {
+ String lowered = fileName.toLowerCase();
+ if( lowered.endsWith( "?wsdl" ))
fileName = fileName.substring( 0, fileName.length() - 5 ) + ".wsdl";
- } else {
+ else if( lowered.contains( "?wsdl=" ))
+ fileName = fileName.replace( "?wsdl=", "" ) + ".wsdl";
+
+ else if( lowered.endsWith( "?xsd" ))
+ fileName = fileName.substring( 0, fileName.length() - 5 ) + ".xsd";
+
+ else if( lowered.contains( "?xsd=" ))
+ fileName = fileName.replace( "?xsd=", "" ) + ".xsd";
+
+ else {
index = fileName.lastIndexOf( '?' );
if( index != -1 )
fileName = fileName.substring( ++ index );
diff --git a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportHelper.java b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportHelper.java
index 807056e..cb5627a 100644
--- a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportHelper.java
+++ b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportHelper.java
@@ -104,6 +104,10 @@
if( relativeFilePath.length() == 0 )
relativeFilePath = UriAndUrlHelper.extractOrGenerateFileName( entry.getKey());
+ else if( ! relativeFilePath.contains( "/" )
+ && ! relativeFilePath.contains( "\\" ))
+ relativeFilePath = UriAndUrlHelper.extractOrGenerateFileName( relativeFilePath );
+
// Imported files which are above the target directory will be put inside a specific directory
IPath path = rootPath.append( relativeFilePath );
if( ! rootPath.isPrefixOf( path ))
@@ -205,9 +209,10 @@
// Absolute URI: we will put them at the same level than the original URI
URI importFullUri = null;
String importFullUriAsString = null;
- if( UriAndUrlHelper.isAbsoluteUri( brutImport ))
+ if( UriAndUrlHelper.isAbsoluteUri( brutImport )) {
+ importFullUri = UriAndUrlHelper.urlToUri( brutImport );
importFullUriAsString = brutImport;
- else {
+ } else {
importFullUri = UriAndUrlHelper.buildNewURI( uri, brutImport );
importFullUriAsString = importFullUri.toString();
}
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportHelperTest.java b/tests/org.eclipse.bpel.common.wsdl.tests/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportHelperTest.java
index 0d765ae..ad773be 100644
--- a/tests/org.eclipse.bpel.common.wsdl.tests/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportHelperTest.java
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportHelperTest.java
@@ -441,6 +441,39 @@
/**
+ * Tests a WSDL 1.1 generated by IIS and hosted on a remote server.
+ * <p>
+ * This test checks specific import locations.
+ * </p>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport14() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ URL url = new URL( "http://api7.publicaster.com/Pub7APIV2/Delivery.svc?wsdl" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 7 );
+ Assert.assertEquals( tmpDir.listFiles().length, 7 );
+
+ File f = map.get( url.toString());
+ Assert.assertNotNull( f );
+ Assert.assertEquals( f.getName(), "Delivery-svc.wsdl" );
+
+ testWsdlParsing( f, 2 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
* Deletes files recursively.
* @param files the files to delete
* @throws IOException if a file could not be deleted