cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r610732 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/ws/addressing/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ tools/javato/ws/src/test/java/...
Date Thu, 10 Jan 2008 09:59:07 GMT
Author: mmao
Date: Thu Jan 10 01:58:54 2008
New Revision: 610732

URL: http://svn.apache.org/viewvc?rev=610732&view=rev
Log:
CXF-1385
  * Add the schemaLocation for the imported schema if the namespace is ws-a


Added:
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/epr/
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/epr/AddNumbersImpl.java
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/JAXWSAConstants.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/JAXWSAConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/JAXWSAConstants.java?rev=610732&r1=610731&r2=610732&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/JAXWSAConstants.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/JAXWSAConstants.java
Thu Jan 10 01:58:54 2008
@@ -37,6 +37,7 @@
     
     public static final String NS_WSA = "http://www.w3.org/2005/08/addressing";
     public static final String WSA_PREFIX = "wsa";
+    public static final String WSA_XSD = "http://www.w3.org/2006/03/addressing/ws-addr.xsd";
     
     public static final String WSA_ERF_NAME = "EndpointReference";
     public static final String WSA_REFERENCEPARAMETERS_NAME = "ReferenceParameters";

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?rev=610732&r1=610731&r2=610732&view=diff
==============================================================================
--- 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
Thu Jan 10 01:58:54 2008
@@ -86,6 +86,7 @@
         //the JAXWS-RI doesn't qualify the schemas for the wrapper types
         //and thus won't work if we do.
         setQualifyWrapperSchema(false);
+        initSchemaLocations();
     }
 
     public JaxWsServiceFactoryBean(JaxWsImplementorInfo implInfo) {
@@ -93,6 +94,11 @@
         this.implInfo = implInfo;
         initConfiguration(implInfo);
         this.serviceClass = implInfo.getEndpointClass();
+    }
+
+    private void initSchemaLocations() {
+        this.schemaLocationMapping.put(JAXWSAConstants.NS_WSA, 
+                                       JAXWSAConstants.WSA_XSD);
     }
 
     @Override

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?rev=610732&r1=610731&r2=610732&view=diff
==============================================================================
--- 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
Thu Jan 10 01:58:54 2008
@@ -134,6 +134,8 @@
 
     protected Class<?> serviceClass;
 
+    protected final Map<String, String> schemaLocationMapping = new HashMap<String,
String>();
+
     private List<AbstractServiceConfiguration> serviceConfigurations = 
         new ArrayList<AbstractServiceConfiguration>();
     private QName serviceName;
@@ -150,7 +152,7 @@
     private boolean qualifiedSchemas = true;
 
     private List<AbstractFeature> features;
-
+    
     public ReflectionServiceFactoryBean() {
         getServiceConfigurations().add(0, new DefaultServiceConfiguration());
 
@@ -980,11 +982,14 @@
     }
 
     private void addImport(XmlSchema schema, String ns) {
-        if (!ns.equals(schema.getTargetNamespace()) && !ns.equals(WSDLConstants.NS_SCHEMA_XSD)
+        if (!ns.equals(schema.getTargetNamespace()) 
+            && !ns.equals(WSDLConstants.NS_SCHEMA_XSD)
             && !isExistImport(schema, ns)) {
-
             XmlSchemaImport is = new XmlSchemaImport();
             is.setNamespace(ns);
+            if (this.schemaLocationMapping.get(ns) != null) {
+                is.setSchemaLocation(this.schemaLocationMapping.get(ns));
+            }
             schema.getItems().add(is);
         }
     }
@@ -1185,6 +1190,7 @@
         SchemaInfo schemaInfo = new SchemaInfo(serviceInfo, namespaceURI);
         SchemaCollection col = serviceInfo.getXmlSchemaCollection();
         XmlSchema schema = col.getSchemaByTargetNamespace(namespaceURI);
+
         if (schema != null) {
             schemaInfo.setSchema(schema);
             serviceInfo.addSchema(schemaInfo);
@@ -1195,7 +1201,6 @@
         if (qualified) {
             schema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
         }
-
         schemaInfo.setSchema(schema);
 
         Map<String, String> explicitNamespaceMappings = this.getDataBinding().getDeclaredNamespaceMappings();

Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/epr/AddNumbersImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/epr/AddNumbersImpl.java?rev=610732&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/epr/AddNumbersImpl.java
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/epr/AddNumbersImpl.java
Thu Jan 10 01:58:54 2008
@@ -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.tools.fortest.epr;
+
+import javax.jws.WebService;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.soap.Addressing;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+@WebService(
+    name = "AddNumbers", 
+    portName = "AddNumbersPort", 
+    targetNamespace = "http://foobar.org/", 
+    serviceName = "AddNumbersService"
+)
+@BindingType(value = SOAPBinding.SOAP11HTTP_BINDING)
+@Addressing(enabled = true, required = true)
+
+public class AddNumbersImpl {
+    WebServiceContext wsc;
+
+    public W3CEndpointReference getW3CEPR() {
+        return (W3CEndpointReference) wsc.getEndpointReference();
+    }
+
+    public int doAddNumbers(int number1, int number2) {
+        return number1 + number2;
+    }
+}

Modified: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?rev=610732&r1=610731&r2=610732&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Thu Jan 10 01:58:54 2008
@@ -556,4 +556,23 @@
         assertTrue(wsdlFile.exists());
         assertTrue(getStringFromFile(wsdlFile).indexOf("elementFormDefault=\"unqualified\"")
!= -1);
     }
+
+    @Test
+    public void testEPR() throws Exception {
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/epr.wsdl");
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.epr.AddNumbersImpl");
+        env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
+        env.put(ToolConstants.CFG_CREATE_XSD_IMPORTS, ToolConstants.CFG_CREATE_XSD_IMPORTS);
+        try {
+            processor.setEnvironment(env);
+            processor.process();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        File wsdlFile = new File(output, "epr_schema1.xsd");
+        assertTrue(wsdlFile.exists());
+        String expectedString = "schemaLocation=\"http://www.w3.org/2006/03/addressing/ws-addr.xsd\"";
+        assertTrue(getStringFromFile(wsdlFile).indexOf(expectedString) != -1);
+    }
 }



Mime
View raw message