cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1567872 - in /cxf/branches/2.6.x-fixes: ./ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/
Date Thu, 13 Feb 2014 09:42:21 GMT
Author: ffang
Date: Thu Feb 13 09:42:21 2014
New Revision: 1567872

URL: http://svn.apache.org/r1567872
Log:
Merged revisions 1567833 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

........
  r1567833 | ffang | 2014-02-13 10:47:19 +0800 (四, 13  2 2014) | 1 line
  
  [CXF-5550]CXF JAX-WS frontend DispatchImpl ignores setting of MessageContext.WSDL_OPERATION
........

Added:
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/DispatchOpTest.java
      - copied unchanged from r1567833, cxf/branches/2.7.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/DispatchOpTest.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/DispatchTest.wsdl
      - copied unchanged from r1567833, cxf/branches/2.7.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/DispatchTest.wsdl
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/OperationRequest.xml
      - copied unchanged from r1567833, cxf/branches/2.7.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/OperationRequest.xml
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/OperationResponse.xml
      - copied unchanged from r1567833, cxf/branches/2.7.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/OperationResponse.xml
Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.7.x-fixes:r1567833

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

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?rev=1567872&r1=1567871&r2=1567872&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
Thu Feb 13 09:42:21 2014
@@ -308,9 +308,12 @@ public class DispatchImpl<T> implements 
             QName opName = (QName)getRequestContext().get(MessageContext.WSDL_OPERATION);
             boolean findDispatchOp = Boolean.TRUE.equals(getRequestContext().get("find.dispatch.operation"));
             
+            boolean hasOpName;
             if (opName == null) {
+                hasOpName = false;
                 opName = isOneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME;
             } else {
+                hasOpName = true;
                 BindingOperationInfo bop = client.getEndpoint().getBinding()
                                             .getBindingInfo().getOperation(opName);
                 if (bop == null) {
@@ -340,10 +343,10 @@ public class DispatchImpl<T> implements 
                     }
                 }
             }
-            Map<String, QName> payloadOPMap = 
-                createPayloadEleOpNameMap(client.getEndpoint().getBinding().getBindingInfo());
+            Map<String, QName> payloadOPMap = createPayloadEleOpNameMap(
+                    client.getEndpoint().getBinding().getBindingInfo(), hasOpName);
             if (findDispatchOp && !payloadOPMap.isEmpty()) {
-                String payloadElementName = null;              
+                QName payloadElementName = null;
                 if (obj instanceof javax.xml.transform.Source) {
                     XMLStreamReader reader = null;
                     try {
@@ -367,7 +370,24 @@ public class DispatchImpl<T> implements 
                 }
 
                 if (payloadElementName != null) {
-                    QName dispatchedOpName = payloadOPMap.get(payloadElementName);
+                    if (hasOpName) {
+                        // Verify the payload element against the given operation name.
+                        // This allows graceful handling of non-standard WSDL definitions
+                        // where different operations have the same payload element.
+                        QName expectedElementName = payloadOPMap.get(opName.toString());
+                        if (expectedElementName == null || !expectedElementName.toString().equals(
+                                payloadElementName.toString())) {
+                            // Verification of the provided operation name failed.
+                            // Resolve the operation name from the payload element.
+                            hasOpName = false;
+                            payloadOPMap = createPayloadEleOpNameMap(
+                                    client.getEndpoint().getBinding().getBindingInfo(), hasOpName);
+                        }
+                    }
+                    QName dispatchedOpName = null;
+                    if (!hasOpName) {
+                        dispatchedOpName = payloadOPMap.get(payloadElementName.toString());
+                    }
                     if (null != dispatchedOpName) {
                         BindingOperationInfo bop = client.getEndpoint().getBinding().getBindingInfo()
                           .getOperation(opName);
@@ -436,7 +456,7 @@ public class DispatchImpl<T> implements 
         return client;
     }
     
-    private String getPayloadElementName(Element ele) {
+    private QName getPayloadElementName(Element ele) {
         XMLStreamReader xmlreader = StaxUtils.createXMLStreamReader(ele);
         DepthXMLStreamReader reader = new DepthXMLStreamReader(xmlreader);
         try {
@@ -444,14 +464,14 @@ public class DispatchImpl<T> implements 
 
                 StaxUtils.skipToStartOfElement(reader);
 
-                return reader.getName().toString();
+                return reader.getName();
             }
             if (this.mode == Service.Mode.MESSAGE) {
                 StaxUtils.skipToStartOfElement(reader);
                 StaxUtils.toNextTag(reader,
                                     new QName(ele.getNamespaceURI(), "Body"));
                 reader.nextTag();
-                return reader.getName().toString();
+                return reader.getName();
             }
         } catch (XMLStreamException e) {
             // ignore
@@ -461,12 +481,12 @@ public class DispatchImpl<T> implements 
     }
     
     
-    private String getPayloadElementName(SOAPMessage soapMessage) {
+    private QName getPayloadElementName(SOAPMessage soapMessage) {
         try {            
             // we only care about the first element node, not text nodes
             Element element = DOMUtils.getFirstElement(SAAJUtils.getBody(soapMessage));
             if (element != null) {
-                return DOMUtils.getElementQName(element).toString();
+                return DOMUtils.getElementQName(element);
             }
         } catch (Exception e) {
             //ignore
@@ -474,7 +494,7 @@ public class DispatchImpl<T> implements 
         return null;
     }
     
-    private String getPayloadElementName(Object object) {
+    private QName getPayloadElementName(Object object) {
         JAXBDataBinding dataBinding = new JAXBDataBinding();
         dataBinding.setContext(context);
         DataWriter<XMLStreamWriter> dbwriter = dataBinding.createWriter(XMLStreamWriter.class);
@@ -492,7 +512,7 @@ public class DispatchImpl<T> implements 
 
                 StaxUtils.skipToStartOfElement(reader);
 
-                return reader.getName().toString();
+                return reader.getName();
 
             }
         } catch (XMLStreamException e) {
@@ -504,7 +524,7 @@ public class DispatchImpl<T> implements 
         return null;
     }
     
-    private Map<String, QName> createPayloadEleOpNameMap(BindingInfo bindingInfo) {
+    private Map<String, QName> createPayloadEleOpNameMap(BindingInfo bindingInfo, boolean
reverseMapping) {
         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";
@@ -526,12 +546,17 @@ public class DispatchImpl<T> implements 
                         && !bop.getOperationInfo().getInput().getMessageParts().isEmpty())
{
                         QName qn = bop.getOperationInfo().getInput().getMessagePartByIndex(0)
                             .getElementQName();
-                        payloadElementMap.put(qn.toString(), bop.getOperationInfo().getName());
+                        QName op = bop.getOperationInfo().getName();
+                        if (reverseMapping) {
+                            payloadElementMap.put(op.toString(), qn);
+                        } else {
+                            payloadElementMap.put(qn.toString(), op);
+                        }
                     }
                 } else if ("rpc".equals(operationStyle)) {
                     // if rpc
-                    payloadElementMap.put(bop.getOperationInfo().getName().toString(), bop.getOperationInfo()
-                        .getName());
+                    QName op = bop.getOperationInfo().getName();
+                    payloadElementMap.put(op.toString(), op);
                 }
             }
         }
@@ -541,5 +566,4 @@ public class DispatchImpl<T> implements 
     public void close() throws IOException {
         client.destroy();
     }
-    
 }



Mime
View raw message