cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r541246 - in /incubator/cxf/trunk: rt/core/src/main/java/org/apache/cxf/wsdl11/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/
Date Thu, 24 May 2007 09:56:39 GMT
Author: mmao
Date: Thu May 24 02:56:37 2007
New Revision: 541246

URL: http://svn.apache.org/viewvc?view=rev&rev=541246
Log:
CXF-669
* Fixed the wrong schema types targetNamespace


Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java?view=diff&rev=541246&r1=541245&r2=541246
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
Thu May 24 02:56:37 2007
@@ -117,7 +117,7 @@
                 Definition portTypeDef = definition;
                 if (!isSameTNS(service)) {
                     portTypeDef = newDefinition(service.getInterface().getName(),
-                                                service.getTargetNamespace());
+                                                service.getInterface().getName().getNamespaceURI());
                     Import wsdlImport = definition.createImport();
                     String tns = service.getInterface().getName().getNamespaceURI();
                     wsdlImport.setDefinition(portTypeDef);

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?view=diff&rev=541246&r1=541245&r2=541246
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
Thu May 24 02:56:37 2007
@@ -236,6 +236,10 @@
         }
     }
 
+    private boolean isSameTNS(final ServiceInfo service) {
+        return service.getName().getNamespaceURI().equals(service.getInterface().getName().getNamespaceURI());
+    }
+    
     public void initialize(Service service) {
         //context is already set, don't redo it
         if (context != null) {
@@ -250,7 +254,11 @@
     
         }
         try {
-            setContext(createJAXBContext(classes, service.getName().getNamespaceURI()));
+            String tns = service.getName().getNamespaceURI();
+            if (service.getServiceInfos().size() > 0) {
+                tns = service.getServiceInfos().get(0).getInterface().getName().getNamespaceURI();
+            }
+            setContext(createJAXBContext(classes, tns));
         } catch (JAXBException e1) {
             throw new ServiceConstructionException(e1);
         }
@@ -270,7 +278,7 @@
                 for (DOMResult r : generateJaxbSchemas()) {
                     Document d = (Document)r.getNode();
                     String ns = d.getDocumentElement().getAttribute("targetNamespace");
-                    if (StringUtils.isEmpty(ns)) {
+                    if (StringUtils.isEmpty(ns) || !isSameTNS(serviceInfo)) {
                         ns = serviceInfo.getInterface().getName().getNamespaceURI();
                         d.getDocumentElement().setAttribute("targetNamespace", ns);
                     }
@@ -286,11 +294,6 @@
                         }
                     }
                     
-                    // Don't include WS-Addressing bits
-                    if ("http://www.w3.org/2005/08/addressing/wsdl".equals(ns)) {
-                        continue;
-                    }
-    
                     SchemaInfo schema = new SchemaInfo(serviceInfo, ns);
                     schema.setElement(d.getDocumentElement());
                     schema.setSystemId(r.getSystemId());
@@ -329,8 +332,11 @@
             public Result createOutput(String ns, String file) throws IOException {
                 DOMResult result = new DOMResult();
                 result.setSystemId(file);
+                // Don't include WS-Addressing bits
+                if ("http://www.w3.org/2005/08/addressing/wsdl".equals(ns)) {
+                    return result;
+                }
                 results.add(result);
-
                 return result;
             }
         });

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java?view=diff&rev=541246&r1=541245&r2=541246
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
Thu May 24 02:56:37 2007
@@ -313,8 +313,8 @@
         assertEquals(new QName("http://foo.com/HelloWorldService", "HelloService"), service.getName());
         assertEquals(new QName("http://foo.com/HelloWorld", "HelloWorld"), service.getInterface().getName());
 
-        // TODO this is not correct, schema namespace should be http://foo.com/HelloWorld
-        assertEquals("http://foo.com/HelloWorldService",
+        assertEquals(1, service.getSchemas().size());
+        assertEquals("http://foo.com/HelloWorld",
                      service.getSchemas().iterator().next().getNamespaceURI());
         
         Collection<BindingInfo> bindings = service.getBindings();
@@ -335,11 +335,16 @@
         String s = IOUtils.toString(new FileInputStream(wsdl));
         assertTrue(s.indexOf("<wsdl:import namespace=\"http://foo.com/HelloWorld\" "
                              + "location=\"HelloWorld.wsdl\">") != -1);
+        assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorldService\"") != -1);
 
         s = IOUtils.toString(new FileInputStream(logical));
 
-        assertTrue(s.indexOf("<import namespace=\"http://foo.com/HelloWorldService\" "
+        assertTrue(s.indexOf("<import namespace=\"http://foo.com/HelloWorld\" "
                              + "schemaLocation=\"HelloService_schema1.xsd\"/>") != -1);
+        assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorld\"") != -1);
+
+        s = IOUtils.toString(new FileInputStream(schema));
+        assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorld\"") != -1);
 
         generator.setAllowImports(oldSetting);
     }



Mime
View raw message