cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r533276 - in /incubator/cxf/trunk/tools: validator/src/main/java/org/apache/cxf/tools/validator/internal/ wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ wsdlto/test/src/test/java/org/apache/cxf/tools/wsd...
Date Sat, 28 Apr 2007 02:28:36 GMT
Author: ema
Date: Fri Apr 27 19:28:35 2007
New Revision: 533276

URL: http://svn.apache.org/viewvc?view=rev&rev=533276
Log:
[CXF-608] Validate the schemas in wsdl before compile with JAXB XJC

Added:
    incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_with_invalid_schema.wsdl
  (with props)
Modified:
    incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
    incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java

Modified: incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java?view=diff&rev=533276&r1=533275&r2=533276
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
Fri Apr 27 19:28:35 2007
@@ -59,7 +59,6 @@
 
             if (m.getName().startsWith("check") || m.getModifiers() == Member.PUBLIC) {
                 try {
-                    System.err.println("invoking" + m.getName());
                     res = (Boolean)m.invoke(this, new Object[] {});
                 } catch (Exception e) {
                     e.printStackTrace();

Modified: incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?view=diff&rev=533276&r1=533275&r2=533276
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Fri Apr 27 19:28:35 2007
@@ -26,7 +26,10 @@
 import java.util.Set;
 import java.util.logging.Logger;
 
+import javax.xml.XMLConstants;
 import javax.xml.namespace.QName;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.validation.SchemaFactory;
 
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
@@ -36,6 +39,7 @@
 import org.w3c.dom.NodeList;
 
 import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 import com.sun.codemodel.JCodeModel;
 import com.sun.tools.xjc.api.Mapping;
@@ -86,7 +90,9 @@
             if (StringUtils.isEmpty(tns)) {
                 continue;
             }
-
+            if (context.get(ToolConstants.CFG_VALIDATE_WSDL) != null) {
+                validateSchema(ele);
+            }
             schemaCompiler.parseSchema(key, ele);
 
         }
@@ -268,5 +274,19 @@
         return clone;
     }
 
+    
+    public void validateSchema(Element ele) throws ToolException {
+        SchemaFactory schemaFact = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        DOMSource domSrc = new DOMSource(ele);
+        try {
+            schemaFact.newSchema(domSrc);
+        } catch (SAXException e) {
+            if (e.getLocalizedMessage().indexOf("src-resolve.4.2") > -1)  {
+                //Ignore schema resolve error and do nothing
+            } else {
+                throw new ToolException("Schema Error : " + e.getLocalizedMessage(), e);
+            }
+        }
+    }
 
 }

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?view=diff&rev=533276&r1=533275&r2=533276
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
Fri Apr 27 19:28:35 2007
@@ -853,4 +853,21 @@
         assertEquals("http://www.w3.org/2001/XMLSchema", webFault.targetNamespace());
 
     }
+    
+    @Test
+    public void testWsdlWithInvalidSchema() {
+        try {
+            env.put(ToolConstants.CFG_WSDLURL, 
+                    getLocation("/wsdl2java_wsdl/hello_world_with_invalid_schema.wsdl"));
+            env.put(ToolConstants.CFG_VALIDATE_WSDL, ToolConstants.CFG_VALIDATE_WSDL);
+            processor.setContext(env);
+            processor.execute();
+        } catch (Exception e) {
+            assertTrue("Jaxb databinding can not find the schema error ", 
+                       e.getLocalizedMessage().indexOf(" cos-st-restricts.1.1: " 
+                                                       + "The type 'TpAny' is atomic") >
-1);
+        }
+    }
+    
+    
 }

Added: incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_with_invalid_schema.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_with_invalid_schema.wsdl?view=auto&rev=533276
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_with_invalid_schema.wsdl
(added)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_with_invalid_schema.wsdl
Fri Apr 27 19:28:35 2007
@@ -0,0 +1,88 @@
+<?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.
+-->
+<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:tns="http://apache.org/hello_world_soap_http"
+    xmlns:x1="http://apache.org/hello_world_soap_http/types"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    targetNamespace="http://apache.org/hello_world_soap_http" name="HelloWorld">
+    <wsdl:types>
+        <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">
+
+            <element name="greetMe">
+                <complexType>
+                    <sequence>
+                        <element name="requestType" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            
+            <simpleType name="TpAny">
+	                 <restriction base="anyType"/>
+            </simpleType>
+            <element name="greetMeResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responseType" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            
+        </schema>
+    </wsdl:types>
+   
+    <wsdl:message name="greetMeRequest">
+        <wsdl:part name="in" element="x1:greetMe"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeResponse">
+        <wsdl:part name="out" element="x1:greetMeResponse"/>
+    </wsdl:message>
+    
+    <wsdl:portType name="Greeter">
+
+        <wsdl:operation name="greetMe">
+            <wsdl:input name="greetMeRequest" message="tns:greetMeRequest"/>
+            <wsdl:output name="greetMeResponse" message="tns:greetMeResponse"/>
+        </wsdl:operation>
+        
+    </wsdl:portType>
+    <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+        <wsdl:operation name="greetMe">
+            <soap:operation style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    
+    <wsdl:service name="SOAPService">
+        <wsdl:port name="SoapPort" binding="tns:Greeter_SOAPBinding">
+            <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+        </wsdl:port>
+    </wsdl:service>
+    
+</wsdl:definitions>
+

Propchange: incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_with_invalid_schema.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_with_invalid_schema.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_with_invalid_schema.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message