cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r892953 - /cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Date Mon, 21 Dec 2009 20:05:07 GMT
Author: dkulp
Date: Mon Dec 21 20:05:07 2009
New Revision: 892953

URL: http://svn.apache.org/viewvc?rev=892953&view=rev
Log:
[CXF-2587] Workaround "bug" in wsdl4j that really isn't looking into
imports like the docs say.

Modified:
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?rev=892953&r1=892952&r2=892953&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Mon Dec 21 20:05:07 2009
@@ -30,6 +30,7 @@
 import javax.wsdl.BindingInput;
 import javax.wsdl.BindingOutput;
 import javax.wsdl.Definition;
+import javax.wsdl.Import;
 import javax.wsdl.Part;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensibilityElement;
@@ -68,6 +69,7 @@
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.AttachmentInInterceptor;
 import org.apache.cxf.interceptor.AttachmentOutInterceptor;
 import org.apache.cxf.interceptor.BareOutInterceptor;
@@ -444,16 +446,52 @@
             SchemaCollection schemas = serviceInfo.getXmlSchemaCollection();
 
             if (def != null && schemas != null) {
-                javax.wsdl.Message msg = def.getMessage(header.getMessage());
+                QName qn = header.getMessage();
+                
+                javax.wsdl.Message msg = findMessage(qn, def);
                 if (msg != null) {
                     addOutOfBandParts(bop, msg, schemas, isInput, header.getPart());
                     serviceInfo.refresh();
                 } else {
                     throw new RuntimeException("Problem with WSDL: soap:header element" 
-                        + " is referring to an undefined wsdl:message element.");
+                        + " for operation " + bop.getName()
+                        + " is referring to an undefined wsdl:message element: " + qn);
+                }
+            }
+        }
+    }
+    private javax.wsdl.Message findMessage(QName qn, Definition def) {
+        javax.wsdl.Message msg = def.getMessage(qn);
+        if (msg == null) {
+            msg = findMessage(qn, def, new ArrayList<Definition>());
+        }
+        return msg;
+    }
+    private javax.wsdl.Message findMessage(QName qn, Definition def, List<Definition>
done) {
+        javax.wsdl.Message msg = def.getMessage(qn);
+        if (msg == null) {
+            if (done.contains(def)) {
+                return null;
+            }
+            done.add(def);
+            Collection<List<Import>> ilist = CastUtils.cast(def.getImports().values());
+            for (List<Import> list : ilist) {
+                for (Import i : list) {
+                    if (qn.getNamespaceURI().equals(i.getDefinition().getTargetNamespace()))
{
+                        return i.getDefinition().getMessage(qn);
+                    }
+                }
+            }
+            for (List<Import> list : ilist) {
+                for (Import i : list) {
+                    msg = findMessage(qn, i.getDefinition(), done);
+                    if (msg != null) {
+                        return msg;
+                    }
                 }
             }
         }
+        return msg;
     }
 
     private void addOutOfBandParts(final BindingOperationInfo bop, final javax.wsdl.Message
msg,



Mime
View raw message