cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1056540 - in /cxf/branches/2.3.x-fixes: ./ 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/
Date Fri, 07 Jan 2011 22:20:00 GMT
Author: dkulp
Date: Fri Jan  7 22:19:59 2011
New Revision: 1056540

URL: http://svn.apache.org/viewvc?rev=1056540&view=rev
Log:
Merged revisions 1056488 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1056488 | dkulp | 2011-01-07 15:18:46 -0500 (Fri, 07 Jan 2011) | 2 lines
  
  [CXF-2687] For schemas set with schemaLocation, make sure any
  imports/includes they have are properly processed for ?wsdl usage
........

Added:
    cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes.xsd
      - copied unchanged from r1056488, cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes.xsd
    cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes2.xsd
      - copied unchanged from r1056488, cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/hello_world_includes2.xsd
Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
    cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
    cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
    cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
    cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1056488

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java?rev=1056540&r1=1056539&r2=1056540&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
Fri Jan  7 22:19:59 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/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java?rev=1056540&r1=1056539&r2=1056540&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
Fri Jan  7 22:19:59 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,63 @@ public class ServiceWSDLBuilder {
                 schemaImpl.setRequired(true);
                 schemaImpl.setElementType(WSDLConstants.QNAME_SCHEMA);
                 schemaImpl.setElement(schemaInfo.getElement());
+                for (int x = 0; x < schemaInfo.getSchema().getIncludes().getCount(); x++)
{
+                    XmlSchemaExternal ext = (XmlSchemaExternal)schemaInfo.getSchema()
+                        .getIncludes().getItem(x);
+                    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/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java?rev=1056540&r1=1056539&r2=1056540&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
Fri Jan  7 22:19:59 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/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java?rev=1056540&r1=1056539&r2=1056540&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
Fri Jan  7 22:19:59 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/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml?rev=1056540&r1=1056539&r2=1056540&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml
(original)
+++ cxf/branches/2.3.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/cxf-servlet.xml
Fri Jan  7 22:19:59 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



Mime
View raw message