You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/08/19 04:00:19 UTC

svn commit: r1159475 - /cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java

Author: dkulp
Date: Fri Aug 19 02:00:19 2011
New Revision: 1159475

URL: http://svn.apache.org/viewvc?rev=1159475&view=rev
Log:
[CXF-3747, CXF-3748, CXF-3749] Fix some issues with dispatch clients and
addressing headers.
Patch from Jesse Pangburn applied.

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?rev=1159475&r1=1159474&r2=1159475&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java Fri Aug 19 02:00:19 2011
@@ -31,7 +31,6 @@ import javax.activation.DataSource;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPFault;
 import javax.xml.soap.SOAPMessage;
@@ -56,6 +55,7 @@ import javax.xml.ws.soap.SOAPFaultExcept
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import org.apache.cxf.binding.soap.model.SoapBindingInfo;
 import org.apache.cxf.binding.soap.model.SoapOperationInfo;
 import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
 import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
@@ -67,6 +67,7 @@ import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.ClientCallback;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.interceptor.AttachmentOutInterceptor;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxb.JAXBDataBinding;
@@ -422,7 +423,7 @@ public class DispatchImpl<T> implements 
             if (this.mode == Service.Mode.MESSAGE) {
                 StaxUtils.skipToStartOfElement(reader);
                 StaxUtils.toNextTag(reader,
-                                    new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body"));
+                                    new QName(ele.getNamespaceURI(), "Body"));
                 reader.nextTag();
                 return reader.getName().toString();
             }
@@ -436,13 +437,15 @@ public class DispatchImpl<T> implements 
     
     private String getPayloadElementName(SOAPMessage soapMessage) {
         try {            
-            SOAPElement element  = (SOAPElement)soapMessage.getSOAPBody().getChildElements().next();
-            return new QName(element.getNamespaceURI(), element.getLocalName()).toString();
+            // we only care about the first element node, not text nodes
+            Element element = DOMUtils.getFirstElement(soapMessage.getSOAPBody());
+            if (element != null) {
+                return DOMUtils.getElementQName(element).toString();
+            }
         } catch (Exception e) {
             //ignore
         }
         return null;
-        
     }
     
     private String getPayloadElementName(Object object) {
@@ -473,10 +476,21 @@ public class DispatchImpl<T> implements 
     
     private Map<String, QName> createPayloadEleOpNameMap(BindingInfo bindingInfo) {
         Map<String, QName> payloadElementMap = new java.util.HashMap<String, QName>();
+        // assume a document binding style, which is default according to W3C spec on WSDL
+        String bindingStyle = "document";
+        // if the bindingInfo is a SOAPBindingInfo instance then we can see if it has a style
+        if (bindingInfo instanceof SoapBindingInfo) {
+            String tempStyle = ((SoapBindingInfo)bindingInfo).getStyle();
+            if (tempStyle != null) {
+                bindingStyle = tempStyle;
+            }
+        }
         for (BindingOperationInfo bop : bindingInfo.getOperations()) {
             SoapOperationInfo soi = (SoapOperationInfo)bop.getExtensor(SoapOperationInfo.class);
             if (soi != null) {
-                if ("document".equals(soi.getStyle())) {
+                // operation style overrides binding style, if present
+                String operationStyle = soi.getStyle() != null ? soi.getStyle() : bindingStyle;  
+                if ("document".equals(operationStyle)) {
                     // if doc
                     if (bop.getOperationInfo().getInput() != null
                         && !bop.getOperationInfo().getInput().getMessageParts().isEmpty()) {
@@ -484,7 +498,7 @@ public class DispatchImpl<T> implements 
                             .getElementQName();
                         payloadElementMap.put(qn.toString(), bop.getOperationInfo().getName());
                     }
-                } else if ("rpc".equals(soi.getStyle())) {
+                } else if ("rpc".equals(operationStyle)) {
                     // if rpc
                     payloadElementMap.put(bop.getOperationInfo().getName().toString(), bop.getOperationInfo()
                         .getName());