cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1404745 - in /cxf/trunk: rt/core/src/main/java/org/apache/cxf/databinding/source/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/
Date Thu, 01 Nov 2012 20:13:26 GMT
Author: dkulp
Date: Thu Nov  1 20:13:26 2012
New Revision: 1404745

URL: http://svn.apache.org/viewvc?rev=1404745&view=rev
Log:
[CXF-4608] Make sure the correct Source form is used if specified and the operation is given

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java?rev=1404745&r1=1404744&r2=1404745&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
Thu Nov  1 20:13:26 2012
@@ -41,8 +41,15 @@ public class SourceDataBinding extends o
     
     public static final String PREFERRED_FORMAT = "source-preferred-format";
 
+    final Class<?> preferred;
+    
     public SourceDataBinding() {
         super();
+        preferred = null;
+    }
+    public SourceDataBinding(Class<?> pref) {
+        super();
+        preferred = pref;
     }
 
     public void initialize(Service service) {
@@ -67,7 +74,7 @@ public class SourceDataBinding extends o
     @SuppressWarnings("unchecked")
     public <T> DataReader<T> createReader(Class<T> cls) {
         if (cls == XMLStreamReader.class) {
-            return (DataReader<T>) new XMLStreamDataReader();
+            return (DataReader<T>) new XMLStreamDataReader(preferred);
         } else if (cls == Node.class) {
             return (DataReader<T>) new NodeDataReader();
         } else {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java?rev=1404745&r1=1404744&r2=1404745&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
Thu Nov  1 20:13:26 2012
@@ -59,14 +59,26 @@ import org.apache.cxf.staxutils.W3CDOMSt
 
 public class XMLStreamDataReader implements DataReader<XMLStreamReader> {
     private static final Logger LOG = LogUtils.getL7dLogger(XMLStreamDataReader.class);
+
+    private final Class<?> preferred;
     private Schema schema;
     private Message message;
     
+    public XMLStreamDataReader() {
+        preferred = null;
+    }
+    public XMLStreamDataReader(Class<?> cls) {
+        preferred = cls;
+    }
+    
     public Object read(MessagePartInfo part, XMLStreamReader input) {
         return read(null, input, part.getTypeClass());
     }
 
     public Object read(final QName name, XMLStreamReader input, Class<?> type) {
+        if (type == null) {
+            type = preferred;
+        }
         if (Source.class.equals(type) && message != null) {
             //generic Source, find the preferred type
             String s = (String)message.getContextualProperty(SourceDataBinding.PREFERRED_FORMAT);

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=1404745&r1=1404744&r2=1404745&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java Thu Nov
 1 20:13:26 2012
@@ -616,7 +616,7 @@ public class ServiceImpl extends Service
             if (context != null) {
                 db = new JAXBDataBinding(context);
             } else {
-                db = new SourceDataBinding();
+                db = new SourceDataBinding(type);
             }
             sf = createDispatchService(db);
         } catch (ServiceConstructionException e) {

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java?rev=1404745&r1=1404744&r2=1404745&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
Thu Nov  1 20:13:26 2012
@@ -45,6 +45,7 @@ import javax.xml.ws.Endpoint;
 import javax.xml.ws.Response;
 import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.soap.SOAPBinding;
 import javax.xml.ws.soap.SOAPFaultException;
 import javax.xml.ws.wsaddressing.W3CEndpointReference;
@@ -861,6 +862,7 @@ public class DispatchClientServerTest ex
         assertNotNull(streamSourceResp3);
         assertTrue("Expected: " + expected, XMLUtils.toString(streamSourceResp3).contains(expected3));
     }
+    
     @Test
     public void testStAXSourcePAYLOAD() throws Exception {
 
@@ -875,7 +877,9 @@ public class DispatchClientServerTest ex
                                      "http://localhost:" 
                                      + greeterPort
                                      + "/SOAPDispatchService/SoapDispatchPort");
-
+        QName opQName = new QName("http://apache.org/hello_world_soap_http", "greetMe");
+        disp.getRequestContext().put(MessageContext.WSDL_OPERATION, opQName);
+        
         // Test request-response
         InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralSOAPBodyReq.xml");
         StAXSource staxSourceReq = new StAXSource(StaxUtils.createXMLStreamReader(is));



Mime
View raw message