cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r542941 - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/test/ databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ ...
Date Wed, 30 May 2007 21:38:14 GMT
Author: dandiep
Date: Wed May 30 14:38:12 2007
New Revision: 542941

URL: http://svn.apache.org/viewvc?view=rev&rev=542941
Log:
Create a schema if one doesn't exist inside JAXBSchemaInitializer. This fixes the case where
a header is in a namespace that doesn't have a schema already built buy the service factory.

Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Foo.java
  (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooService.java
  (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooServiceImpl.java
  (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/jaxb.index
  (with props)
Removed:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/AbstractJaxWsServiceFactoryBean.java
Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java?view=diff&rev=542941&r1=542940&r2=542941
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java Wed
May 30 14:38:12 2007
@@ -30,6 +30,12 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLWriter;
+
+import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -38,15 +44,18 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.ConduitInitiator;
 import org.apache.cxf.transport.ConduitInitiatorManager;
 import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -220,6 +229,18 @@
         }
 
         return basedirPath;
+    }
+
+    protected Document getWSDLDocument(Server server) throws WSDLException {
+        Service service = server.getEndpoint().getService();
+        
+        ServiceWSDLBuilder wsdlBuilder = 
+            new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0));
+        wsdlBuilder.setUseSchemaImports(false);
+        Definition definition = wsdlBuilder.build();
+        WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+        
+        return writer.getDocument(definition);
     }
     
     public static class TestMessageObserver implements MessageObserver {

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?view=diff&rev=542941&r1=542940&r2=542941
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
Wed May 30 14:38:12 2007
@@ -90,6 +90,7 @@
         }
         
         boolean isElement = beanInfo.isElement();
+        
         part.setElement(isElement);
         if (isElement) {
             QName name = new QName(beanInfo.getElementNamespaceURI(null), 
@@ -141,20 +142,48 @@
                     if (s.getNamespaceURI().equals(qn.getNamespaceURI())) {
                         schemaInfo = s;
 
-                        el = new XmlSchemaElement();
-                        el.setQName(part.getElementQName());
-                        el.setName(part.getElementQName().getLocalPart());
-                        el.setNillable(true);
+                        createXsElement(part, typeName, schemaInfo);
+
                         schemaInfo.getSchema().getItems().add(el);
                         
-                        el.setSchemaTypeName(typeName);
                         return;
                     }
                 }
+                
+                schemaInfo = new SchemaInfo(serviceInfo, qn.getNamespaceURI());
+                el = createXsElement(part, typeName, schemaInfo);
+
+                XmlSchema schema = new XmlSchema(qn.getNamespaceURI(), schemas);
+                schemaInfo.setSchema(schema);
+                schema.getItems().add(el);
+
+                NamespaceMap nsMap = new NamespaceMap();
+                nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NU_SCHEMA_XSD);
+                schema.setNamespaceContext(nsMap);
+                
+                Document[] docs;
+                try {
+                    docs = XmlSchemaSerializer.serializeSchema(schema, false);
+                } catch (XmlSchemaSerializerException e1) {
+                    throw new ServiceConstructionException(e1);
+                }
+                Element e = docs[0].getDocumentElement();
+                
+                schemaInfo.setElement(e);
+                serviceInfo.addSchema(schemaInfo);
             }
         }
         
         
+    }
+
+    private XmlSchemaElement createXsElement(MessagePartInfo part, QName typeName, SchemaInfo
schemaInfo) {
+        XmlSchemaElement el = new XmlSchemaElement();
+        el.setQName(part.getElementQName());
+        el.setName(part.getElementQName().getLocalPart());
+        el.setNillable(true);
+        el.setSchemaTypeName(typeName);
+        return el;
     }
     
     public void end(FaultInfo fault) {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?view=diff&rev=542941&r1=542940&r2=542941
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Wed May 30 14:38:12 2007
@@ -70,7 +70,7 @@
  *
  * @see org.apache.cxf.jaxws.JaxWsServerFactoryBean
  */
-public class JaxWsServiceFactoryBean extends AbstractJaxWsServiceFactoryBean {
+public class JaxWsServiceFactoryBean extends ReflectionServiceFactoryBean {
     private static final Logger LOG = LogUtils.getL7dLogger(JaxWsServiceFactoryBean.class);
     
     private AbstractServiceConfiguration jaxWsConfiguration;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java?view=diff&rev=542941&r1=542940&r2=542941
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
Wed May 30 14:38:12 2007
@@ -31,11 +31,13 @@
 import org.w3c.dom.Node;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.jaxws.service.ArrayService;
 import org.apache.cxf.jaxws.service.ArrayServiceImpl;
+import org.apache.cxf.jaxws.service.FooServiceImpl;
 import org.apache.cxf.jaxws.service.Hello;
 import org.apache.cxf.jaxws.service.HelloInterface;
 import org.apache.cxf.jaxws.service.SayHi;
@@ -265,5 +267,18 @@
         assertEquals(proxy.listInput(listIn), "list1list2list3");
     }
 
+    @Test
+    public void testNamespacedWebParams() throws Exception {
+        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+        sf.setAddress("http://localhost/test");
+        sf.setServiceClass(FooServiceImpl.class);
+        
+        Server server = sf.create();
+        
+        Document doc = getWSDLDocument(server);
+        
+        assertValid("//xsd:schema[@targetNamespace='http://namespace3']", doc);
+        assertValid("//xsd:schema[@targetNamespace='http://namespace5']", doc);
+    }
 
 }

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Foo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Foo.java?view=auto&rev=542941
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Foo.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Foo.java
Wed May 30 14:38:12 2007
@@ -0,0 +1,23 @@
+/**
+ * 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.jaxws.service;
+
+public class Foo {
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Foo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Foo.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Foo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooService.java?view=auto&rev=542941
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooService.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooService.java
Wed May 30 14:38:12 2007
@@ -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.jaxws.service;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+@WebService
+@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+public interface FooService {
+//    @WebResult(name = "FooElementResult", targetNamespace = "http://namespace2")
+//    Foo echo(@WebParam(name = "FooElementRequest", targetNamespace = "http://namespace1")
+//             Foo foo);
+
+    @WebMethod(operationName = "FooEcho2", action = "http://namespace4")
+    @WebResult(name = "FooEcho2Result", partName = "fooPart", header = true, 
+               targetNamespace = "http://namespace5")
+    Foo echo2(@WebParam(name = "FooEcho2Request", header = true, 
+                        targetNamespace = "http://namespace3")
+              Foo foo, String name);
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooService.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooServiceImpl.java?view=auto&rev=542941
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooServiceImpl.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooServiceImpl.java
Wed May 30 14:38:12 2007
@@ -0,0 +1,35 @@
+/**
+ * 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.jaxws.service;
+
+import javax.jws.WebService;
+
+@WebService(endpointInterface = "org.apache.cxf.jaxws.service.FooService")
+public class FooServiceImpl implements FooService {
+
+    public Foo echo(Foo foo) {
+        return foo;
+    }
+
+    public Foo echo2(Foo foo, String name) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooServiceImpl.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/FooServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/jaxb.index
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/jaxb.index?view=auto&rev=542941
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/jaxb.index
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/jaxb.index
Wed May 30 14:38:12 2007
@@ -0,0 +1 @@
+Foo
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/jaxb.index
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=542941&r1=542940&r2=542941
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Wed May 30 14:38:12 2007
@@ -581,13 +581,7 @@
             el.setNillable(true);
 
             if (mpi.isElement()) {
-                el.setRefName(mpi.getElementQName());
-                String ns = mpi.getElementQName().getNamespaceURI();
-                if (!ns.equals(schema.getTargetNamespace()) && !ns.equals(WSDLConstants.NU_SCHEMA_XSD))
{
-                    XmlSchemaImport is = new XmlSchemaImport();
-                    is.setNamespace(ns);
-                    schema.getItems().add(is);
-                }
+                continue;
             } else {
                 el.setSchemaTypeName(mpi.getTypeQName());
                 String ns = mpi.getTypeQName().getNamespaceURI();



Mime
View raw message