cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r661823 - in /cxf/branches/2.0.x-fixes: ./ api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
Date Fri, 30 May 2008 19:16:58 GMT
Author: dkulp
Date: Fri May 30 12:16:58 2008
New Revision: 661823

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

........
  r661821 | dkulp | 2008-05-30 15:10:31 -0400 (Fri, 30 May 2008) | 2 lines
  
  Collect all the schemas in the schemaCollection upfront to create the schema for validation.
........

Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java

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

Modified: cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java?rev=661823&r1=661822&r2=661823&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
(original)
+++ cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
Fri May 30 12:16:58 2008
@@ -24,7 +24,7 @@
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.net.URL;
-import java.util.ArrayList;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.logging.Level;
@@ -533,20 +533,46 @@
         Schema schema = serviceInfo.getProperty(Schema.class.getName(), Schema.class);
         if (schema == null) {
             SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
-            List<Source> schemaSources = new ArrayList<Source>();
-            for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) {
-                Source source = new DOMSource(schemaInfo.getElement());
-                String baseURI = schemaInfo.getElement().getBaseURI();
-                if (baseURI != null) {
-                    source.setSystemId(baseURI);
-                } else {
-                    source.setSystemId(schemaInfo.getSystemId());
-                }
-                schemaSources.add(source);
+            Map<String, Source> schemaSourcesMap = new LinkedHashMap<String, Source>();
+            for (SchemaInfo si : serviceInfo.getSchemas()) {
+                Element el = si.getElement();
+                String baseURI = el.getBaseURI();
+                if (baseURI == null) {
+                    baseURI = si.getSystemId();
+                }
+                DOMSource ds = new DOMSource(el, baseURI);                
+                schemaSourcesMap.put(si.getSystemId() + ":" + si.getNamespaceURI(), ds);
             }
+
+            for (XmlSchema sch : serviceInfo.getXmlSchemaCollection().getXmlSchemas()) {
+                if (sch.getSourceURI() != null
+                    && !schemaSourcesMap.containsKey(sch.getSourceURI() + ":" 
+                                                     + sch.getTargetNamespace())) { 
+                    
+                    InputStream ins = null;
+                    try {
+                        URL url = new URL(sch.getSourceURI());
+                        ins = url.openStream();
+                    } catch (Exception e) {
+                        //ignore, we'll just use what we have.  (though
+                        //bugs in XmlSchema could make this less useful)
+                    }
+                    
+                    if (ins == null) {
+                        LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
+                        sch.write(out);
+                        ins = out.createInputStream();
+                    }
+                    StreamSource ss = new StreamSource(ins, sch.getSourceURI());
+                    schemaSourcesMap.put(sch.getSourceURI() + ":" 
+                                         + sch.getTargetNamespace(), ss);
+                }
+            } 
+
             try {
                 factory.setResourceResolver(new SchemaLSResourceResolver(serviceInfo));
-                schema = factory.newSchema(schemaSources.toArray(new Source[schemaSources.size()]));
+                schema = factory.newSchema(schemaSourcesMap.values()
+                                           .toArray(new Source[schemaSourcesMap.size()]));
             } catch (SAXException ex) {
                 // Something not right with the schema from the wsdl.
                 LOG.log(Level.WARNING, "SAXException for newSchema() on ", ex);



Mime
View raw message