You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by em...@apache.org on 2014/03/06 11:37:43 UTC
[2/2] git commit: [CXF-4910]:Schema can not be retrived if two
imported schemas have the same relative schema location
[CXF-4910]:Schema can not be retrived if two imported schemas have the same relative schema location
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/69766331
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/69766331
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/69766331
Branch: refs/heads/2.7.x-fixes
Commit: 69766331ca11095b584d4ea00f5643a927a987df
Parents: 4faeb62
Author: jimma <em...@redhat.com>
Authored: Thu Mar 6 17:54:55 2014 +0800
Committer: Jim Ma <em...@apache.org>
Committed: Thu Mar 6 18:37:18 2014 +0800
----------------------------------------------------------------------
.../org/apache/cxf/common/util/UrlUtils.java | 8 +-
.../org/apache/cxf/frontend/WSDLGetUtils.java | 98 ++++++++++++++------
.../apache/cxf/systest/schemaimport/SayHi.java | 50 ++++++++++
.../cxf/systest/schemaimport/SayHiImpl.java | 64 +++++++++++++
.../systest/schemaimport/SchemaImportTest.java | 78 ++++++++++++++++
.../apache/cxf/systest/schemaimport/Server.java | 48 ++++++++++
.../cxf/systest/schemaimport/sayhi1/SayHi.java | 39 ++++++++
.../schemaimport/sayhi1/SayHiResponse.java | 41 ++++++++
.../systest/schemaimport/sayhi2/SayHiArray.java | 40 ++++++++
.../schemaimport/sayhi2/SayHiArrayResponse.java | 42 +++++++++
.../src/test/resources/wsdl_systest/sayHi.wsdl | 63 +++++++++++++
.../test/resources/wsdl_systest/sayhi/a.wsdl | 29 ++++++
.../wsdl_systest/sayhi/sayhi-schema1.xsd | 38 ++++++++
.../resources/wsdl_systest/sayhi/sayhi/a.wsdl | 27 ++++++
.../wsdl_systest/sayhi/sayhi/sayhi-schema1.xsd | 37 ++++++++
15 files changed, 669 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/api/src/main/java/org/apache/cxf/common/util/UrlUtils.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/common/util/UrlUtils.java b/api/src/main/java/org/apache/cxf/common/util/UrlUtils.java
index 07fcdb7..1e16677 100644
--- a/api/src/main/java/org/apache/cxf/common/util/UrlUtils.java
+++ b/api/src/main/java/org/apache/cxf/common/util/UrlUtils.java
@@ -20,7 +20,6 @@
package org.apache.cxf.common.util;
import java.io.UnsupportedEncodingException;
-import java.net.URI;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
@@ -108,13 +107,12 @@ public final class UrlUtils {
* @return the trailing
*/
public static String getStem(String baseURI) {
- URI uri = URI.create(baseURI);
- baseURI = uri.getRawPath();
int idx = baseURI.lastIndexOf('/');
+ String result = baseURI;
if (idx != -1) {
- baseURI = baseURI.substring(0, idx);
+ result = baseURI.substring(0, idx);
}
- return URI.create(baseURI).getPath();
+ return result;
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
index eb84670..ef9f9f6 100644
--- a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
+++ b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
@@ -22,6 +22,7 @@ package org.apache.cxf.frontend;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.Collection;
@@ -56,6 +57,7 @@ import org.apache.cxf.Bus;
import org.apache.cxf.catalog.OASISCatalogManager;
import org.apache.cxf.catalog.OASISCatalogManagerHelper;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.UrlUtils;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.message.Message;
@@ -66,6 +68,7 @@ import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.wsdl.WSDLManager;
import org.apache.cxf.wsdl11.ResourceManagerWSDLLocator;
import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
+import org.springframework.util.StringUtils;
/**
*
@@ -142,7 +145,6 @@ public class WSDLGetUtils {
if (prop != null) {
base = String.valueOf(prop);
}
-
String wsdl = params.get("wsdl");
if (wsdl != null) {
// Always use the URL decoded version to ensure that we have a
@@ -188,7 +190,7 @@ public class WSDLGetUtils {
Definition def = builder.build(new HashMap<String, SchemaInfo>());
mp.put("", def);
- updateDefinition(bus, def, mp, smp, base, endpointInfo);
+ updateDefinition(bus, def, mp, smp, base, endpointInfo, "");
}
@@ -258,7 +260,7 @@ public class WSDLGetUtils {
}
}
- updateDoc(doc, base, mp, smp, message);
+ updateDoc(doc, base, mp, smp, message, xsd, wsdl);
return doc;
} catch (WSDLQueryException wex) {
@@ -270,11 +272,19 @@ public class WSDLGetUtils {
}
}
- protected String mapUri(String base, Map<String, SchemaReference> smp, String loc)
+ protected String mapUri(String base, Map<String, SchemaReference> smp, String loc, String xsd)
throws UnsupportedEncodingException {
- SchemaReference ref = smp.get(URLDecoder.decode(loc, "utf-8"));
+ String key = loc;
+ try {
+ if (!(new URI(loc).isAbsolute()) && xsd != null && !UrlUtils.getStem(xsd).equals(xsd)) {
+ key = UrlUtils.getStem(xsd) + "/" + loc;
+ }
+ } catch (URISyntaxException e) {
+ //ignore
+ }
+ SchemaReference ref = smp.get(URLDecoder.decode(key, "utf-8"));
if (ref != null) {
- return base + "?xsd=" + ref.getSchemaLocationURI().replace(" ", "%20");
+ return base + "?xsd=" + key.replace(" ", "%20");
}
return null;
}
@@ -283,16 +293,17 @@ public class WSDLGetUtils {
String base,
Map<String, Definition> mp,
Map<String, SchemaReference> smp,
- Message message) {
+ Message message,
+ String xsd,
+ String wsdl) {
List<Element> elementList = null;
try {
elementList = DOMUtils.findAllElementsByTagNameNS(doc.getDocumentElement(),
- "http://www.w3.org/2001/XMLSchema",
- "import");
+ "http://www.w3.org/2001/XMLSchema", "import");
for (Element el : elementList) {
String sl = el.getAttribute("schemaLocation");
- sl = mapUri(base, smp, sl);
+ sl = mapUri(base, smp, sl, xsd);
if (sl != null) {
el.setAttribute("schemaLocation", sl);
}
@@ -321,6 +332,13 @@ public class WSDLGetUtils {
"import");
for (Element el : elementList) {
String sl = el.getAttribute("location");
+ try {
+ if (!StringUtils.isEmpty(wsdl) && !(new URI(sl).isAbsolute())) {
+ sl = UrlUtils.getStem(wsdl) + "/" + sl;
+ }
+ } catch (URISyntaxException e) {
+ //ignore
+ }
if (mp.containsKey(URLDecoder.decode(sl, "utf-8"))) {
el.setAttribute("location", base + "?wsdl=" + sl.replace(" ", "%20"));
}
@@ -419,19 +437,19 @@ public class WSDLGetUtils {
protected void updateDefinition(Bus bus,
Definition def, Map<String, Definition> done,
Map<String, SchemaReference> doneSchemas,
- String base, EndpointInfo ei) {
+ String base, EndpointInfo ei, String docBase) {
OASISCatalogManager catalogs = OASISCatalogManager.getCatalogManager(bus);
Collection<List<?>> imports = CastUtils.cast((Collection<?>)def.getImports().values());
for (List<?> lst : imports) {
List<Import> impLst = CastUtils.cast(lst);
for (Import imp : impLst) {
-
String start = imp.getLocationURI();
String decodedStart = null;
// Always use the URL decoded version to ensure that we have a
// canonical representation of the import URL for lookup.
- try {
+
+ try {
decodedStart = URLDecoder.decode(start, "utf-8");
} catch (UnsupportedEncodingException e) {
throw new WSDLQueryException(
@@ -447,14 +465,23 @@ public class WSDLGetUtils {
//check to see if it's already in a URL format. If so, leave it.
new URL(start);
} catch (MalformedURLException e) {
+ try {
+ if (!(new URI(docBase).isAbsolute()) && !(new URI(start).isAbsolute())
+ && !StringUtils.isEmpty(docBase)) {
+ start = UrlUtils.getStem(docBase) + "/" + start;
+ decodedStart = URLDecoder.decode(start, "utf-8");
+ }
+ } catch (Exception e1) {
+ //ignore
+ }
if (done.put(decodedStart, imp.getDefinition()) == null) {
- updateDefinition(bus, imp.getDefinition(), done, doneSchemas, base, ei);
+ updateDefinition(bus, imp.getDefinition(), done, doneSchemas, base, ei, start);
}
}
} else {
if (done.put(decodedStart, imp.getDefinition()) == null) {
done.put(resolvedSchemaLocation, imp.getDefinition());
- updateDefinition(bus, imp.getDefinition(), done, doneSchemas, base, ei);
+ updateDefinition(bus, imp.getDefinition(), done, doneSchemas, base, ei, start);
}
}
}
@@ -470,7 +497,7 @@ public class WSDLGetUtils {
: CastUtils.cast(types.getExtensibilityElements(), ExtensibilityElement.class)) {
if (el instanceof Schema) {
Schema see = (Schema)el;
- updateSchemaImports(bus, see, doneSchemas, base);
+ updateSchemaImports(bus, see, see.getDocumentBaseURI(), doneSchemas, base);
}
}
}
@@ -523,6 +550,7 @@ public class WSDLGetUtils {
protected void updateSchemaImports(Bus bus,
Schema schema,
+ String docBase,
Map<String, SchemaReference> doneSchemas,
String base) {
OASISCatalogManager catalogs = OASISCatalogManager.getCatalogManager(bus);
@@ -530,7 +558,7 @@ public class WSDLGetUtils {
for (List<?> lst : imports) {
List<SchemaImport> impLst = CastUtils.cast(lst);
for (SchemaImport imp : impLst) {
- String start = findSchemaLocation(doneSchemas, imp);
+ String start = findSchemaLocation(doneSchemas, imp, docBase);
if (start != null) {
String decodedStart = null;
@@ -553,13 +581,13 @@ public class WSDLGetUtils {
new URL(start);
} catch (MalformedURLException e) {
if (doneSchemas.put(decodedStart, imp) == null) {
- updateSchemaImports(bus, imp.getReferencedSchema(), doneSchemas, base);
+ updateSchemaImports(bus, imp.getReferencedSchema(), docBase, doneSchemas, base);
}
}
} else {
if (doneSchemas.put(decodedStart, imp) == null) {
doneSchemas.put(resolvedSchemaLocation, imp);
- updateSchemaImports(bus, imp.getReferencedSchema(), doneSchemas, base);
+ updateSchemaImports(bus, imp.getReferencedSchema(), docBase, doneSchemas, base);
}
}
}
@@ -569,7 +597,7 @@ public class WSDLGetUtils {
List<SchemaReference> includes = CastUtils.cast(schema.getIncludes());
for (SchemaReference included : includes) {
- String start = findSchemaLocation(doneSchemas, included);
+ String start = findSchemaLocation(doneSchemas, included, docBase);
if (start != null) {
String decodedStart = null;
@@ -592,7 +620,7 @@ public class WSDLGetUtils {
new URL(start);
} catch (MalformedURLException e) {
if (doneSchemas.put(decodedStart, included) == null) {
- updateSchemaImports(bus, included.getReferencedSchema(), doneSchemas, base);
+ updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
}
}
}
@@ -600,13 +628,13 @@ public class WSDLGetUtils {
|| !doneSchemas.containsKey(resolvedSchemaLocation)) {
doneSchemas.put(decodedStart, included);
doneSchemas.put(resolvedSchemaLocation, included);
- updateSchemaImports(bus, included.getReferencedSchema(), doneSchemas, base);
+ updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
}
}
}
List<SchemaReference> redefines = CastUtils.cast(schema.getRedefines());
for (SchemaReference included : redefines) {
- String start = findSchemaLocation(doneSchemas, included);
+ String start = findSchemaLocation(doneSchemas, included, docBase);
if (start != null) {
String decodedStart = null;
@@ -629,7 +657,7 @@ public class WSDLGetUtils {
new URL(start);
} catch (MalformedURLException e) {
if (doneSchemas.put(decodedStart, included) == null) {
- updateSchemaImports(bus, included.getReferencedSchema(), doneSchemas, base);
+ updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
}
}
}
@@ -637,24 +665,38 @@ public class WSDLGetUtils {
|| !doneSchemas.containsKey(resolvedSchemaLocation)) {
doneSchemas.put(decodedStart, included);
doneSchemas.put(resolvedSchemaLocation, included);
- updateSchemaImports(bus, included.getReferencedSchema(), doneSchemas, base);
+ updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
}
}
}
}
- private String findSchemaLocation(Map<String, SchemaReference> doneSchemas, SchemaReference imp) {
+ private String findSchemaLocation(Map<String, SchemaReference> doneSchemas, SchemaReference imp, String docBase) {
+ String schemaLocationURI = imp.getSchemaLocationURI();
+ if (docBase != null && imp.getReferencedSchema() != null) {
+ try {
+ String baseURI = URLDecoder.decode(UrlUtils.getStem(docBase), "utf-8");
+ String importURI = URLDecoder.decode(imp.getReferencedSchema().getDocumentBaseURI(), "utf-8");
+ if (importURI.contains(baseURI)) {
+ schemaLocationURI = importURI.substring(baseURI.length() + 1);
+ }
+ } catch (Exception e) {
+ //ignore
+ }
+
+ }
+
if (imp.getReferencedSchema() != null) {
for (Map.Entry<String, SchemaReference> e : doneSchemas.entrySet()) {
if (e.getValue().getReferencedSchema().getElement()
== imp.getReferencedSchema().getElement()) {
- doneSchemas.put(imp.getSchemaLocationURI(), imp);
+ doneSchemas.put(schemaLocationURI, imp);
imp.setSchemaLocationURI(e.getKey());
return e.getKey();
}
}
}
- return imp.getSchemaLocationURI();
+ return schemaLocationURI;
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SayHi.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SayHi.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SayHi.java
new file mode 100644
index 0000000..a1e2116
--- /dev/null
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SayHi.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.schemaimport;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+@WebService(targetNamespace = "http://apache.org/sayHi", name = "SayHi")
+public interface SayHi {
+
+ @WebResult(name = "return", targetNamespace = "")
+ @RequestWrapper(localName = "sayHiArray",
+ targetNamespace = "http://apache.org/sayHi2",
+ className = "org.apache.sayhi2.SayHiArray")
+ @WebMethod
+ @ResponseWrapper(localName = "sayHiArrayResponse",
+ targetNamespace = "http://apache.org/sayHi2",
+ className = "org.apache.sayhi2.SayHiArrayResponse")
+ java.util.List<String> sayHiArray(@WebParam(name = "arg0", targetNamespace = "")
+ java.util.List<String> arg0);
+
+ @WebResult(name = "return", targetNamespace = "http://apache.org/sayHi1")
+ @RequestWrapper(localName = "sayHi", targetNamespace = "http://apache.org/sayHi1",
+ className = "org.apache.sayhi1.SayHi")
+ @WebMethod
+ @ResponseWrapper(localName = "sayHiResponse",
+ targetNamespace = "http://apache.org/sayHi1",
+ className = "org.apache.sayhi1.SayHiResponse")
+ String sayHi(@WebParam(name = "arg0", targetNamespace = "http://apache.org/sayHi1") String arg0);
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SayHiImpl.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SayHiImpl.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SayHiImpl.java
new file mode 100644
index 0000000..cb2e548
--- /dev/null
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SayHiImpl.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.schemaimport;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+@WebService(targetNamespace = "http://apache.org/sayHi", name = "SayHi",
+ wsdlLocation = "classpath:/wsdl_systest/sayHi.wsdl",
+ endpointInterface = "org.apache.cxf.systest.schemaimport.SayHi")
+public class SayHiImpl implements SayHi {
+
+ @Override
+ @WebResult(name = "return", targetNamespace = "")
+ @RequestWrapper(localName = "sayHiArray",
+ targetNamespace = "http://apache.org/sayHi2",
+ className = "org.apache.sayhi2.SayHiArray")
+ @WebMethod
+ @ResponseWrapper(localName = "sayHiArrayResponse",
+ targetNamespace = "http://apache.org/sayHi2",
+ className = "org.apache.sayhi2.SayHiArrayResponse")
+ public List<String> sayHiArray(@WebParam(name = "arg0", targetNamespace = "") List<String> arg0) {
+ List<String> list = new ArrayList<String>();
+ list.add("Hi");
+ return list;
+ }
+
+ @Override
+ @WebResult(name = "return", targetNamespace = "http://apache.org/sayHi1")
+ @RequestWrapper(localName = "sayHi",
+ targetNamespace = "http://apache.org/sayHi1",
+ className = "org.apache.sayhi1.SayHi")
+ @WebMethod
+ @ResponseWrapper(localName = "sayHiResponse",
+ targetNamespace = "http://apache.org/sayHi1",
+ className = "org.apache.sayhi1.SayHiResponse")
+ public String sayHi(@WebParam(name = "arg0", targetNamespace = "http://apache.org/sayHi1") String arg0) {
+ return "Hi";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SchemaImportTest.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SchemaImportTest.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SchemaImportTest.java
new file mode 100644
index 0000000..a1c4f28
--- /dev/null
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SchemaImportTest.java
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.schemaimport;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class SchemaImportTest extends AbstractBusClientServerTestBase {
+ public static final String PORT = Server.PORT;
+
+ @BeforeClass
+ public static void startservers() throws Exception {
+ assertTrue("server did not launch correctly", launchServer(Server.class, true));
+ }
+
+ @Test
+ public void testImportSchema() throws Exception {
+ String schemaURL = "http://localhost:" + PORT + "/schemaimport/sayHi" + "?xsd=sayhi/sayhi/sayhi-schema1.xsd";
+ System.out.println(schemaURL);
+ URL url = new URL(schemaURL);
+ InputStream ins = null;
+ try {
+ ins = url.openStream();
+ String output = IOUtils.toString(ins);
+ assertTrue(output.indexOf("sayHiArray") > -1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Can not access the import schema");
+ } finally {
+ if (ins != null) {
+ ins.close();
+ }
+ }
+ }
+
+ @Test
+ public void testImportWsdl() throws Exception {
+ String schemaURL = "http://localhost:" + PORT + "/schemaimport/sayHi" + "?wsdl=sayhi/sayhi/a.wsdl";
+ URL url = new URL(schemaURL);
+ InputStream ins = null;
+ try {
+ ins = url.openStream();
+ String output = IOUtils.toString(ins);
+ assertTrue(output.indexOf("sayHiArray") > -1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Can not access the import wsdl");
+
+ } finally {
+ if (ins != null) {
+ ins.close();
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/Server.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/Server.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/Server.java
new file mode 100644
index 0000000..752f1b0
--- /dev/null
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/Server.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.schemaimport;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server extends AbstractBusTestServerBase {
+ public static final String PORT = allocatePort(Server.class);
+
+ public Server() {
+ }
+
+ protected void run() {
+ Object implementor = new SayHiImpl();
+ String address = "http://localhost:" + PORT + "/schemaimport/sayHi";
+ Endpoint.publish(address, implementor);
+ }
+
+ public static void main(String[] args) {
+ try {
+ Server s = new Server();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi1/SayHi.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi1/SayHi.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi1/SayHi.java
new file mode 100644
index 0000000..5d8200f
--- /dev/null
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi1/SayHi.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.schemaimport.sayhi1;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "sayHi", propOrder = { "arg0" })
+public class SayHi {
+
+ protected String arg0;
+
+ public String getArg0() {
+ return arg0;
+ }
+
+ public void setArg0(String value) {
+ this.arg0 = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi1/SayHiResponse.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi1/SayHiResponse.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi1/SayHiResponse.java
new file mode 100644
index 0000000..2051475
--- /dev/null
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi1/SayHiResponse.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.schemaimport.sayhi1;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "sayHiResponse", propOrder = { "res" })
+public class SayHiResponse {
+
+ @XmlElement(name = "res")
+ protected String res;
+
+ public String getReturn() {
+ return res;
+ }
+
+ public void setReturn(String value) {
+ this.res = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi2/SayHiArray.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi2/SayHiArray.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi2/SayHiArray.java
new file mode 100644
index 0000000..2412a6b
--- /dev/null
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi2/SayHiArray.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.schemaimport.sayhi2;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "sayHiArray", propOrder = { "arg0" })
+public class SayHiArray {
+
+ protected List<String> arg0;
+
+ public List<String> getArg0() {
+ if (arg0 == null) {
+ arg0 = new ArrayList<String>();
+ }
+ return this.arg0;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi2/SayHiArrayResponse.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi2/SayHiArrayResponse.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi2/SayHiArrayResponse.java
new file mode 100644
index 0000000..c9a3803
--- /dev/null
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/sayhi2/SayHiArrayResponse.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.schemaimport.sayhi2;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "sayHiArrayResponse", propOrder = { "res" })
+public class SayHiArrayResponse {
+
+ @XmlElement(name = "res")
+ protected List<String> res;
+
+ public List<String> getReturn() {
+ if (res == null) {
+ res = new ArrayList<String>();
+ }
+ return this.res;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/resources/wsdl_systest/sayHi.wsdl
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/sayHi.wsdl b/systests/uncategorized/src/test/resources/wsdl_systest/sayHi.wsdl
new file mode 100644
index 0000000..c8b09c8
--- /dev/null
+++ b/systests/uncategorized/src/test/resources/wsdl_systest/sayHi.wsdl
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<definitions xmlns:tns="http://apache.org/sayHi" xmlns:sayhi1="http://apache.org/sayHi1" xmlns:sayhi2="http://apache.org/sayHi2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://apache.org/sayHi" name="SayHiService">
+ <import namespace="http://apache.org/sayHi" location="sayhi/a.wsdl"/>
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://apache.org/sayHi1" schemaLocation="sayhi/sayhi-schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <portType name="SayHi">
+ <operation name="sayHi">
+ <input message="tns:sayHi"/>
+ <output message="tns:sayHiResponse"/>
+ </operation>
+ <operation name="sayHiArray">
+ <input message="tns:sayHiArray"/>
+ <output message="tns:sayHiArrayResponse"/>
+ </operation>
+ </portType>
+ <binding name="SayHiPortBinding" type="tns:SayHi">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="sayHi">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="sayHiArray">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="SayHiService">
+ <port name="SayHiPort" binding="tns:SayHiPortBinding">
+ <soap:address location="http://localhost:9090/sayHi"/>
+ </port>
+ </service>
+</definitions>
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/a.wsdl
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/a.wsdl b/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/a.wsdl
new file mode 100644
index 0000000..4641052
--- /dev/null
+++ b/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/a.wsdl
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<definitions xmlns:tns="http://apache.org/sayHi" xmlns:sayhi1="http://apache.org/sayHi1" xmlns:sayhi2="http://apache.org/sayHi2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://apache.org/sayHi" name="SayHiService">
+ <import namespace="http://apache.org/sayHi" location="sayhi/a.wsdl"/>
+ <message name="sayHi">
+ <part name="parameters" element="sayhi1:sayHi"/>
+ </message>
+ <message name="sayHiResponse">
+ <part name="parameters" element="sayhi1:sayHiResponse"/>
+ </message>
+
+</definitions>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi-schema1.xsd
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi-schema1.xsd b/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi-schema1.xsd
new file mode 100644
index 0000000..a089a21
--- /dev/null
+++ b/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi-schema1.xsd
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://apache.org/sayHi1" xmlns:x1="http://apache.org/sayHi1" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+ <xs:import namespace="http://apache.org/sayHi2" schemaLocation="sayhi/sayhi-schema1.xsd"/>
+ <xs:element name="sayHi" type="x1:sayHi"/>
+
+ <xs:complexType name="sayHi">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="sayHiResponse" type="x1:sayHiResponse"/>
+
+ <xs:complexType name="sayHiResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi/a.wsdl
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi/a.wsdl b/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi/a.wsdl
new file mode 100644
index 0000000..5487510
--- /dev/null
+++ b/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi/a.wsdl
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<definitions xmlns:tns="http://apache.org/sayHi" xmlns:sayhi1="http://apache.org/sayHi1" xmlns:sayhi2="http://apache.org/sayHi2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://apache.org/sayHi" name="SayHiService">
+ <message name="sayHiArray">
+ <part name="parameters" element="sayhi2:sayHiArray"/>
+ </message>
+ <message name="sayHiArrayResponse">
+ <part name="parameters" element="sayhi2:sayHiArrayResponse"/>
+ </message>
+</definitions>
http://git-wip-us.apache.org/repos/asf/cxf/blob/69766331/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi/sayhi-schema1.xsd
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi/sayhi-schema1.xsd b/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi/sayhi-schema1.xsd
new file mode 100644
index 0000000..4b14693
--- /dev/null
+++ b/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/sayhi/sayhi-schema1.xsd
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<xs:schema targetNamespace="http://apache.org/sayHi2" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="sayHiArray" type="ns1:sayHiArray" xmlns:ns1="http://apache.org/sayHi2"/>
+
+ <xs:complexType name="sayHiArray">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" maxOccurs="unbounded" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="sayHiArrayResponse" type="ns2:sayHiArrayResponse" xmlns:ns2="http://apache.org/sayHi2"/>
+
+ <xs:complexType name="sayHiArrayResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" maxOccurs="unbounded" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>