You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/01/07 21:18:46 UTC
svn commit: r1056488 - in /cxf/trunk:
rt/core/src/main/java/org/apache/cxf/transport/http/
rt/core/src/main/java/org/apache/cxf/wsdl11/
systests/transports/src/test/java/org/apache/cxf/systest/servlet/
Author: dkulp
Date: Fri Jan 7 20:18:46 2011
New Revision: 1056488
URL: http://svn.apache.org/viewvc?rev=1056488&view=rev
Log:
[CXF-2687] For schemas set with schemaLocation, make sure any
imports/includes they have are properly processed for ?wsdl usage
Added:
cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes.xsd (with props)
cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes2.xsd
- copied, changed from r1056487, cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java?rev=1056488&r1=1056487&r2=1056488&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java Fri Jan 7 20:18:46 2011
@@ -253,7 +253,6 @@ public class WSDLQueryHandler implements
EndpointInfo ei) {
List<Element> elementList = null;
-
try {
elementList = DOMUtils.findAllElementsByTagNameNS(doc.getDocumentElement(),
"http://www.w3.org/2001/XMLSchema",
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java?rev=1056488&r1=1056487&r2=1056488&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java Fri Jan 7 20:18:46 2011
@@ -50,6 +50,8 @@ import javax.wsdl.extensions.AttributeEx
import javax.wsdl.extensions.ElementExtensible;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.extensions.schema.SchemaImport;
+import javax.wsdl.extensions.schema.SchemaReference;
import javax.xml.namespace.QName;
import javax.xml.parsers.ParserConfigurationException;
@@ -78,6 +80,11 @@ import org.apache.cxf.service.model.Sche
import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.ws.addressing.NSManager;
import org.apache.cxf.wsdl.WSDLManager;
+import org.apache.ws.commons.schema.XmlSchemaExternal;
+import org.apache.ws.commons.schema.XmlSchemaImport;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.XmlSchemaRedefine;
+import org.apache.ws.commons.schema.XmlSchemaSerializer.XmlSchemaSerializerException;
/**
* Consume a set of service definitions and produce a WSDL model. The ServiceInfo objects
@@ -292,6 +299,61 @@ public class ServiceWSDLBuilder {
schemaImpl.setRequired(true);
schemaImpl.setElementType(WSDLConstants.QNAME_SCHEMA);
schemaImpl.setElement(schemaInfo.getElement());
+ for (XmlSchemaExternal ext : schemaInfo.getSchema().getExternals()) {
+ if (ext.getSchema() == null) {
+ continue;
+ }
+ if (ext instanceof XmlSchemaImport) {
+ SchemaImport imp = schemaImpl.createImport();
+ imp.setNamespaceURI(((XmlSchemaImport)ext).getNamespace());
+ imp.setSchemaLocationURI(((XmlSchemaImport)ext).getSchemaLocation());
+
+ SchemaImpl schemaImpl2 = new SchemaImpl();
+ schemaImpl2.setRequired(true);
+ schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
+ schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
+ try {
+ schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
+ } catch (XmlSchemaSerializerException e) {
+ //ignore
+ }
+ imp.setReferencedSchema(schemaImpl2);
+
+ schemaImpl.addImport(imp);
+ } else if (ext instanceof XmlSchemaInclude) {
+ SchemaReference imp = schemaImpl.createInclude();
+ imp.setSchemaLocationURI(((XmlSchemaInclude)ext).getSchemaLocation());
+
+ SchemaImpl schemaImpl2 = new SchemaImpl();
+ schemaImpl2.setRequired(true);
+ schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
+ schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
+ try {
+ schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
+ } catch (XmlSchemaSerializerException e) {
+ //ignore
+ }
+ imp.setReferencedSchema(schemaImpl2);
+
+ schemaImpl.addInclude(imp);
+ } else if (ext instanceof XmlSchemaRedefine) {
+ SchemaReference imp = schemaImpl.createRedefine();
+ imp.setSchemaLocationURI(((XmlSchemaRedefine)ext).getSchemaLocation());
+
+ SchemaImpl schemaImpl2 = new SchemaImpl();
+ schemaImpl2.setRequired(true);
+ schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
+ schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
+ try {
+ schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
+ } catch (XmlSchemaSerializerException e) {
+ //ignore
+ }
+ imp.setReferencedSchema(schemaImpl2);
+
+ schemaImpl.addRedefine(imp);
+ }
+ }
types.addExtensibilityElement(schemaImpl);
} else {
//imports
Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java?rev=1056488&r1=1056487&r2=1056488&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java (original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java Fri Jan 7 20:18:46 2011
@@ -39,6 +39,7 @@ import org.apache.cxf.BusException;
import org.apache.cxf.BusFactory;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.testsupport.AbstractServletTest;
+import org.apache.hello_world_soap_http.BaseGreeterImpl;
import org.junit.Before;
import org.junit.Test;
@@ -96,7 +97,7 @@ public class CXFServletTest extends Abst
WebLink[] links = res.getLinks();
- assertEquals("There should get two links for the service", 2, links.length);
+ assertEquals("There should get two links for the service", 3, links.length);
Set<String> links2 = new HashSet<String>();
for (WebLink l : links) {
@@ -116,7 +117,7 @@ public class CXFServletTest extends Abst
links2.add(l.getURLString());
}
- assertEquals("There should get two links for the service", 2, links.length);
+ assertEquals("There should get two links for the service", 3, links.length);
assertTrue(links2.contains(CONTEXT_URL + "/services/greeter?wsdl"));
assertTrue(links2.contains(CONTEXT_URL + "/services/greeter2?wsdl"));
@@ -143,6 +144,33 @@ public class CXFServletTest extends Abst
assertValid("//wsdl:operation[@name='greetMe']", doc);
assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/greeter']", doc);
}
+ @Test
+ public void testGetWSDLWithIncludes() throws Exception {
+ ServletUnitClient client = newClient();
+ client.setExceptionsThrownOnErrorStatus(true);
+
+ WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter3?wsdl");
+
+ WebResponse res = client.getResponse(req);
+ assertEquals(200, res.getResponseCode());
+ assertEquals("text/xml", res.getContentType());
+ Document doc = DOMUtils.readXml(res.getInputStream());
+ assertNotNull(doc);
+
+ assertXPathEquals("//xsd:include/@schemaLocation",
+ "http://localhost/mycontext/services/greeter3?xsd=hello_world_includes2.xsd",
+ doc.getDocumentElement());
+
+ req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter3?xsd=hello_world_includes2.xsd");
+
+ res = client.getResponse(req);
+ assertEquals(200, res.getResponseCode());
+ assertEquals("text/xml", res.getContentType());
+ doc = DOMUtils.readXml(res.getInputStream());
+ assertNotNull(doc);
+
+ assertValid("//xsd:complexType[@name='ErrorCode']", doc);
+ }
@Test
public void testGetWSDLWithXMLBinding() throws Exception {
@@ -217,4 +245,12 @@ public class CXFServletTest extends Abst
return "Hello " + name;
}
}
+ @WebService(serviceName = "SOAPService",
+ portName = "SoapPort",
+ endpointInterface = "org.apache.hello_world_soap_http.Greeter",
+ targetNamespace = "http://apache.org/hello_world_soap_http")
+ public static class NoWsdlGreeter extends BaseGreeterImpl {
+
+
+ }
}
Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java?rev=1056488&r1=1056487&r2=1056488&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java (original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java Fri Jan 7 20:18:46 2011
@@ -60,7 +60,7 @@ public class ExternalServicesServletTest
//test the '/' context get service list
WebResponse res = client.getResponse(CONTEXT_URL + "/");
WebLink[] links = res.getLinks();
- assertEquals("There should get two links for the services", 2, links.length);
+ assertEquals("There should get two links for the services", 3, links.length);
Set<String> links2 = new HashSet<String>();
for (WebLink l : links) {
Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml?rev=1056488&r1=1056487&r2=1056488&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml (original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml Fri Jan 7 20:18:46 2011
@@ -34,7 +34,15 @@ http://cxf.apache.org/jaxws http://cxf.a
id="greeter2"
address="/greeter2"
implementor="org.apache.hello_world_xml_http.wrapped.GreeterImpl"
- wsdlLocation="/org/apache/cxf/systest/servlet/hello_world_xml_wrapped.wsdl" />
+ wsdlLocation="/org/apache/cxf/systest/servlet/hello_world_xml_wrapped.wsdl" />
+
+ <jaxws:endpoint
+ id="greeter3"
+ address="/greeter3"
+ implementor="org.apache.cxf.systest.servlet.CXFServletTest$NoWsdlGreeter">
+ <jaxws:schemaLocations >
+ <jaxws:schemaLocation>/org/apache/cxf/systest/servlet/hello_world_includes.xsd</jaxws:schemaLocation>
+ </jaxws:schemaLocations>
+ </jaxws:endpoint>
-
</beans>
\ No newline at end of file
Added: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes.xsd?rev=1056488&view=auto
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes.xsd (added)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes.xsd Fri Jan 7 20:18:46 2011
@@ -0,0 +1,150 @@
+<?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.
+-->
+<schema targetNamespace="http://apache.org/hello_world_soap_http/types" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:x1="http://apache.org/hello_world_soap_http/types" elementFormDefault="qualified">
+ <include schemaLocation="hello_world_includes2.xsd"/>
+ <element name="sayHi">
+ <annotation>
+ <documentation>Hello sayHi users!</documentation>
+ </annotation>
+ <complexType/>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="testNillable">
+ <complexType>
+ <sequence>
+ <element name="NillElem" nillable="true" type="string"/>
+ <element name="intElem" type="int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testNillableResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" nillable="true" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="greetMeLater">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="long"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeLaterResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeSometime">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeSometimeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeOneWay">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testDocLitFault">
+ <complexType>
+ <sequence>
+ <element name="faultType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testDocLitFaultResponse">
+ <complexType>
+ <sequence/>
+ </complexType>
+ </element>
+ <element name="NoSuchCodeLit">
+ <complexType>
+ <sequence>
+ <element name="code" type="x1:ErrorCode"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="BadRecordLit" type="string"/>
+ <complexType name="BadRecord">
+ <sequence>
+ <element name="reason" type="string"/>
+ <element name="code" type="short"/>
+ </sequence>
+ </complexType>
+ <complexType name="addNumbers">
+ <sequence>
+ <element name="arg0" type="int"/>
+ <element name="arg1" type="int"/>
+ </sequence>
+ </complexType>
+ <element name="addNumbers" type="x1:addNumbers"/>
+ <complexType name="addNumbersResponse">
+ <sequence>
+ <element name="return" type="int"/>
+ </sequence>
+ </complexType>
+ <element name="addNumbersResponse" type="x1:addNumbersResponse"/>
+ <element name="BareDocument" type="string"/>
+ <element name="BareDocumentResponse">
+ <complexType>
+ <sequence>
+ <element name="company" type="string"/>
+ </sequence>
+ <attribute name="id" type="int"/>
+ </complexType>
+ </element>
+</schema>
+
Propchange: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes.xsd
------------------------------------------------------------------------------
svn:mime-type = text/xml
Copied: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes2.xsd (from r1056487, cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml)
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes2.xsd?p2=cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes2.xsd&p1=cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml&r1=1056487&r2=1056488&rev=1056488&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml (original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes2.xsd Fri Jan 7 20:18:46 2011
@@ -7,9 +7,9 @@
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
@@ -17,24 +17,18 @@
specific language governing permissions and limitations
under the License.
-->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:jaxws="http://cxf.apache.org/jaxws"
- xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
-
- <jaxws:endpoint
- id="greeter1"
- address="/greeter"
- implementor="org.apache.hello_world_soap_http.GreeterImpl"
- wsdlLocation="/org/apache/cxf/systest/servlet/hello_world.wsdl" />
-
- <jaxws:endpoint
- id="greeter2"
- address="/greeter2"
- implementor="org.apache.hello_world_xml_http.wrapped.GreeterImpl"
- wsdlLocation="/org/apache/cxf/systest/servlet/hello_world_xml_wrapped.wsdl" />
-
+<schema targetNamespace="http://apache.org/hello_world_soap_http/types" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:x1="http://apache.org/hello_world_soap_http/types" elementFormDefault="qualified">
+ <complexType name="ErrorCode">
+ <sequence>
+ <element name="minor" type="short"/>
+ <element name="major" type="short"/>
+ </sequence>
+ </complexType>
+ <complexType name="stringStruct">
+ <sequence>
+ <element name="arg0" type="string"/>
+ <element name="arg1" type="string"/>
+ </sequence>
+ </complexType>
+</schema>
-</beans>
\ No newline at end of file