cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r822507 - in /cxf/branches/2.2.x-fixes: ./ common/common/src/main/java/org/apache/cxf/helpers/ rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/ rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/ systests/data...
Date Tue, 06 Oct 2009 21:18:24 GMT
Author: dkulp
Date: Tue Oct  6 21:18:24 2009
New Revision: 822507

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

........
  r822376 | dkulp | 2009-10-06 13:54:05 -0400 (Tue, 06 Oct 2009) | 2 lines
  
  [CXF-2442] fixes and testcases for using xsd's in a wsdl for use with
  xmlbeans
........

Added:
    cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/PutLastTradePriceImpl.java
      - copied unchanged from r822376, cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/PutLastTradePriceImpl.java
    cxf/branches/2.2.x-fixes/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/doc_lit_bare.wsdl
      - copied unchanged from r822376, cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/doc_lit_bare.wsdl
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java
    cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
    cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
    cxf/branches/2.2.x-fixes/systests/databinding/pom.xml
    cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java
    cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/Server.java
    cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ServerNoWsdl.java
    cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf.xml
    cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml

Propchange: cxf/branches/2.2.x-fixes/
            ('svn:mergeinfo' removed)

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

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java?rev=822507&r1=822506&r2=822507&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java
Tue Oct  6 21:18:24 2009
@@ -24,9 +24,11 @@
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathFactory;
 
 import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 public class XPathUtils {
     private static final XPathFactory FACTORY = XPathFactory.newInstance();
@@ -56,6 +58,15 @@
             return null;
         }
     }
+    public NodeList getValueList(String xpathExpression, Node node) {
+        return (NodeList)getValue(xpathExpression, node, XPathConstants.NODESET);
+    }
+    public String getValueString(String xpathExpression, Node node) {
+        return (String)getValue(xpathExpression, node, XPathConstants.STRING);
+    }
+    public Node getValueNode(String xpathExpression, Node node) {
+        return (Node)getValue(xpathExpression, node, XPathConstants.NODE);
+    }
 
     public boolean isExist(String xpathExpression, Node node, QName type) {
         return getValue(xpathExpression, node, type) != null;

Modified: cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java?rev=822507&r1=822506&r2=822507&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
Tue Oct  6 21:18:24 2009
@@ -25,6 +25,7 @@
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
@@ -36,15 +37,18 @@
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 
 import org.xml.sax.InputSource;
 
 
+import org.apache.cxf.common.WSDLConstants;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.service.ServiceModelVisitor;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.ServiceInfo;
@@ -118,36 +122,61 @@
         }
     }
 
+    XmlSchema addSchemaElement(SchemaTypeSystem sts, Document doc, 
+                          Element elem, String file) throws URISyntaxException {
+        doc.appendChild(elem);
+        
+        elem = DOMUtils.getFirstElement(elem);
+        while (elem != null) {
+            if (elem.getLocalName().equals("import")) {
+                URI uri = new URI(file);
+                String loc = elem.getAttribute("schemaLocation");
+                if (!StringUtils.isEmpty(loc)) {
+                    URI locUri = uri.resolve(loc);
+                    String newLoc = locUri.toString();
+                    getSchema(sts, newLoc);
+                }
+            }                 
+            elem = DOMUtils.getNextElement(elem);
+        }
+        XmlSchema schema = dataBinding.addSchemaDocument(serviceInfo,
+                                                         schemas, 
+                                                         doc, 
+                                                         file);
+        doc.removeChild(doc.getDocumentElement());
+        schemaMap.put(file, schema);
+
+        return schema;
+    }
     XmlSchema getSchema(SchemaTypeSystem sts, String file) {
         if (schemaMap.containsKey(file)) {
             return schemaMap.get(file);
         }
         InputStream ins = sts.getSourceAsStream(file);
+        if (ins == null) {
+            return null;
+        }
         try {
             //temporary marker to make sure recursive imports don't blow up
             schemaMap.put(file, null);
 
             Document doc = XMLUtils.parse(ins);
-            Element elem = DOMUtils.getFirstElement(doc.getDocumentElement());
-            while (elem != null) {
-                if (elem.getLocalName().equals("import")) {
-                    URI uri = new URI(file);
-                    String loc = elem.getAttribute("schemaLocation");
-                    if (!StringUtils.isEmpty(loc)) {
-                        URI locUri = uri.resolve(loc);
-                        String newLoc = locUri.toString();
-                        getSchema(sts, newLoc);
-                    }
-                }                 
-                elem = DOMUtils.getNextElement(elem);
-            }
-                
-            XmlSchema schema = dataBinding.addSchemaDocument(serviceInfo,
-                                                             schemas, 
-                                                             doc, 
-                                                             file);
-            schemaMap.put(file, schema);
-            return schema;
+            Element elem = doc.getDocumentElement();
+            doc.removeChild(elem);
+            
+            if ("schema".equals(elem.getLocalName())
+                && "http://www.w3.org/2001/XMLSchema".equals(elem.getNamespaceURI()))
{
+                return addSchemaElement(sts, doc, elem, file);
+            }
+            Map<String, String> ns = new HashMap<String, String>();
+            ns.put("wsdl", WSDLConstants.NS_WSDL11);
+            ns.put("xsd", WSDLConstants.NS_SCHEMA_XSD);
+            XPathUtils xpath = new XPathUtils(ns);
+            NodeList list = xpath.getValueList("/wsdl:definitions/wsdl:types/xsd:schema",
elem);
+            for (int x = 0; x < list.getLength(); x++) {
+                addSchemaElement(sts, doc, (Element)list.item(x), file + "#1");
+            }
+            return null;
         } catch (Exception e) {
             throw new RuntimeException("Failed to find schema for: " + file, e);
         }
@@ -201,26 +230,40 @@
             SchemaTypeSystem sts = st.getTypeSystem();
             schemas.getXmlSchemaCollection().setSchemaResolver(new XMLSchemaResolver(sts));
             String sourceName = st.getSourceName();
-            if (sourceName.endsWith("wsdl")) {
-                return;
-            }
             XmlSchema schema = getSchema(sts, sourceName);
-
-            if (st.isDocumentType()) {
-                XmlSchemaElement sct = schema.getElementByName(st.getDocumentElementName());
-                part.setXmlSchema(sct);
-                part.setElement(true);
-                part.setElementQName(st.getDocumentElementName());
-                part.setConcreteName(st.getDocumentElementName());
-            } else if (st.getComponentType() == SchemaType.ELEMENT) {
-                XmlSchemaElement sct = schema.getElementByName(st.getName());
-                part.setXmlSchema(sct);
-                part.setElement(true);
+            if (schema != null) {
+                if (st.isDocumentType()) {
+                    XmlSchemaElement sct = schema.getElementByName(st.getDocumentElementName());
+                    part.setXmlSchema(sct);
+                    part.setElement(true);
+                    part.setElementQName(st.getDocumentElementName());
+                    part.setConcreteName(st.getDocumentElementName());
+                } else if (st.getComponentType() == SchemaType.ELEMENT) {
+                    XmlSchemaElement sct = schema.getElementByName(st.getName());
+                    part.setXmlSchema(sct);
+                    part.setElement(true);
+                } else {
+                    XmlSchemaType sct = schema.getTypeByName(st.getName());
+                    part.setTypeQName(st.getName());
+                    part.setXmlSchema(sct);
+                    part.setElement(false);
+                }
             } else {
-                XmlSchemaType sct = schema.getTypeByName(st.getName());
-                part.setTypeQName(st.getName());
-                part.setXmlSchema(sct);
-                part.setElement(false);
+                if (st.isDocumentType()) {
+                    part.setElement(true);
+                    part.setElementQName(st.getDocumentElementName());
+                    part.setConcreteName(st.getDocumentElementName());
+                    part.setXmlSchema(schemas.getElementByQName(st.getDocumentElementName()));
+                } else if (st.getComponentType() == SchemaType.ELEMENT) {
+                    part.setElement(true);
+                    part.setElementQName(st.getName());
+                    part.setConcreteName(st.getName());
+                    part.setXmlSchema(schemas.getElementByQName(st.getName()));
+                } else {
+                    part.setTypeQName(st.getName());
+                    part.setElement(false);
+                    part.setXmlSchema(schemas.getTypeByQName(st.getName()));
+                }
             }
         } catch (RuntimeException ex) {
             throw ex;

Modified: cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java?rev=822507&r1=822506&r2=822507&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
Tue Oct  6 21:18:24 2009
@@ -21,6 +21,8 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.io.Writer;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -40,6 +42,7 @@
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
@@ -63,6 +66,7 @@
 import org.apache.xmlbeans.impl.schema.PathResourceLoader;
 import org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl;
 import org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler;
+import org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl;
 import org.apache.xmlbeans.impl.schema.StscState;
 import org.apache.xmlbeans.impl.tool.CodeGenUtil;
 import org.apache.xmlbeans.impl.util.FilerImpl;
@@ -215,6 +219,20 @@
                 System.out.println(s);
             }
             */
+            for (Map.Entry<String, String> ent : sourcesToCopyMap.entrySet()) {
+                try {
+                    OutputStream out = filer.createBinaryFile("schema" 
+                                                              + SchemaTypeSystemImpl.METADATA_PACKAGE_GEN
+                                                              + "/src/" + ent.getValue());
+                    URL url = new URL(ent.getKey());
+                    InputStream in = url.openStream();
+                    IOUtils.copy(in, out);
+                    out.close();
+                    in.close();
+                } catch (Exception e) {
+                    //probably not an issue
+                }
+            }
         }
 
         if (!result) {
@@ -240,7 +258,6 @@
         if (cpResourceLoader != null) {
             cpResourceLoader.close();
         }
-
     }
 
     
@@ -269,6 +286,7 @@
             
 
             XmlObject urldoc = loader.parse(url, null, options);
+            state.addSourceUri(wsdlFile, null);
 
             if (urldoc instanceof org.apache.xmlbeans.impl.xb.substwsdl.DefinitionsDocument)
{
                 org.apache.xmlbeans.impl.xb.substwsdl.DefinitionsDocument wsdldoc = 

Modified: cxf/branches/2.2.x-fixes/systests/databinding/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/databinding/pom.xml?rev=822507&r1=822506&r2=822507&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/databinding/pom.xml (original)
+++ cxf/branches/2.2.x-fixes/systests/databinding/pom.xml Tue Oct  6 21:18:24 2009
@@ -82,6 +82,7 @@
                                     <includes>
                                         <include>**/*.xsb</include>
                                         <include>**/*.class</include>
+                                        <include>**/*.wsdl</include>
                                     </includes>
                                 </resource>
                             </resources>
@@ -108,6 +109,13 @@
                                         <extraarg>xmlbeans</extraarg>
                                     </extraargs>
                                 </wsdlOption>
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/test/resources/wsdl_systest_databinding/xmlbeans/doc_lit_bare.wsdl</wsdl>
+                                    <extraargs>
+                                        <extraarg>-db</extraarg>
+                                        <extraarg>xmlbeans</extraarg>
+                                    </extraargs>
+                                </wsdlOption>
                             </wsdlOptions>
                         </configuration>
                         <goals>

Modified: cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java?rev=822507&r1=822506&r2=822507&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java
Tue Oct  6 21:18:24 2009
@@ -30,7 +30,6 @@
 @javax.jws.WebService(portName = "SoapPort", serviceName = "SOAPService", 
                       targetNamespace = "http://apache.org/hello_world_soap_http/xmlbeans",

                       endpointInterface = "org.apache.hello_world_soap_http.xmlbeans.Greeter")
-                  
 public class GreeterImpl implements Greeter {
 
     private static final Logger LOG = LogUtils.getL7dLogger(GreeterImpl.class);        

Modified: cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/Server.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/Server.java?rev=822507&r1=822506&r2=822507&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/Server.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/Server.java
Tue Oct  6 21:18:24 2009
@@ -35,9 +35,11 @@
         Bus bus = factory.createBus("org/apache/cxf/systest/xmlbeans/cxf.xml");
         BusFactory.setDefaultBus(bus);
         setBus(bus);
-        Object implementor = new GreeterImpl();
-        String address = "http://localhost:9000/SoapContext/SoapPort";
-        Endpoint.publish(address, implementor);
+        Endpoint.publish("http://localhost:9000/SoapContext/SoapPort",
+                         new GreeterImpl());
+        
+        Endpoint.publish("http://localhost:9000/SOAPDocLitBareService/SoapPort", 
+                         new PutLastTradePriceImpl());
     }
 
     public static void main(String args[]) {

Modified: cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ServerNoWsdl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ServerNoWsdl.java?rev=822507&r1=822506&r2=822507&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ServerNoWsdl.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ServerNoWsdl.java
Tue Oct  6 21:18:24 2009
@@ -38,6 +38,9 @@
         Object implementor = new GreeterImpl();
         String address = "http://localhost:9010/SoapContext/SoapPort";
         Endpoint.publish(address, implementor);
+        
+        implementor = new PutLastTradePriceImpl();
+        Endpoint.publish("http://localhost:9010/SOAPDocLitBareService/SoapPort", implementor);
     }
 
     public static void main(String args[]) {

Modified: cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf.xml?rev=822507&r1=822506&r2=822507&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf.xml
(original)
+++ cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf.xml
Tue Oct  6 21:18:24 2009
@@ -26,28 +26,25 @@
 http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
 http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
 
-    <!-- comment this bean to disable schema validation in the client -->
 
     <jaxws:client name="{http://apache.org/hello_world_soap_http/xmlbeans}SoapPort"
         createdFromAPI="true">
         <!-- jaxws:properties>
             <entry key="schema-validation-enabled" value="true" />
         </jaxws:properties-->
-        <!-- jaxws:dataBinding>
-        	<bean class="org.apache.cxf.xmlbeans.XmlBeansDataBinding"/>
-        </jaxws:dataBinding-->
     </jaxws:client>
 
     <jaxws:endpoint name="{http://apache.org/hello_world_soap_http/xmlbeans}SoapPort"
-        wsdlLocation="wsdl_systest_databinding/xmlbeans/hello_world.wsdl"
+        wsdlLocation="classpath:wsdl_systest_databinding/xmlbeans/hello_world.wsdl"
         createdFromAPI="true">
         <jaxws:properties>
             <entry key="schema-validation-enabled" value="true" />
         </jaxws:properties>
-        <!-- jaxws:dataBinding>
-        	<bean class="org.apache.cxf.xmlbeans.XmlBeansDataBinding"/>
-        </jaxws:dataBinding-->
     </jaxws:endpoint>
-
+    
+    
+    <jaxws:endpoint name="{http://cxf.apache.org/xmlbeans/doc_lit_bare}SoapPort"
+        wsdlLocation="classpath:wsdl_systest_databinding/xmlbeans/doc_lit_bare.wsdl"
+        createdFromAPI="true"/>
 </beans>
 

Modified: cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml?rev=822507&r1=822506&r2=822507&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml
(original)
+++ cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml
Tue Oct  6 21:18:24 2009
@@ -47,6 +47,9 @@
         	<bean class="org.apache.cxf.xmlbeans.XmlBeansDataBinding"/>
         </jaxws:dataBinding>
     </jaxws:endpoint>
-
+    
+    <jaxws:endpoint name="{http://cxf.apache.org/xmlbeans/doc_lit_bare}SoapPort"
+        wsdlLocation="wsdl_systest_databinding/xmlbeans/doc_lit_bare.wsdl"
+        createdFromAPI="true"/>
 </beans>
 



Mime
View raw message