cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r472125 - in /incubator/cxf/trunk: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ systests/src/test/java/org/apache/cxf/systest/ws/rm/
Date Tue, 07 Nov 2006 14:33:44 GMT
Author: eglynn
Date: Tue Nov  7 06:33:42 2006
New Revision: 472125

URL: http://svn.apache.org/viewvc?view=rev&rev=472125
Log:
Fixes for:
- HTTPConduit incorrectly discarding partial responses to oneway requests
- SOAPOutInterceptor starting <SOAP:Body> element before it ends the
  <SOAP:Header> element in certain circumstances

Modified:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java?view=diff&rev=472125&r1=472124&r2=472125
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
Tue Nov  7 06:33:42 2006
@@ -77,8 +77,11 @@
                     StaxUtils.writeElement(eleHeaders, xtw, true, false);
                 }
             }
-            handleHeaderPart(preexistingHeaders, message);
-       
+            boolean endedHeader = handleHeaderPart(preexistingHeaders, message);
+            if (preexistingHeaders && !endedHeader) {
+                xtw.writeEndElement();
+            }
+
             xtw.writeStartElement(soapVersion.getPrefix(), 
                                   soapVersion.getBody().getLocalPart(),
                                   soapVersion.getNamespace());
@@ -105,33 +108,34 @@
         }
     }
     
-    private void handleHeaderPart(boolean preexistingHeaders, SoapMessage message) {
+    private boolean handleHeaderPart(boolean preexistingHeaders, SoapMessage message) {
         //add MessagePart to soapHeader if necessary
+        boolean endedHeader = false;
         Exchange exchange = message.getExchange();
         BindingOperationInfo bop = (BindingOperationInfo)exchange.get(BindingOperationInfo.class
                                                                             .getName());
         if (bop == null) {
-            return;
+            return endedHeader;
         }
         XMLStreamWriter xtw = message.getContent(XMLStreamWriter.class);        
         boolean startedHeader = false;
         List<MessagePartInfo> parts = new ArrayList<MessagePartInfo>();
         BindingMessageInfo bmi = isRequestor(message) ? bop.getInput() : bop.getOutput();
         if (bmi == null) {
-            return;
+            return endedHeader;
         } else {
             parts = bmi.getMessageInfo().getMessageParts();
         } 
         if (parts.size() > 0) {
             List<?> objs = message.getContent(List.class);
             if (objs == null) {
-                return;
+                return endedHeader;
             }            
             Object[] args = objs.toArray();
             SoapVersion soapVersion = message.getVersion();
             List<SoapHeaderInfo> headers = bmi.getExtensors(SoapHeaderInfo.class);
             if (headers == null) {
-                return;
+                return endedHeader;
             }
             for (SoapHeaderInfo header : headers) {
                 Object arg = args[header.getSequence()];
@@ -161,6 +165,7 @@
             if (startedHeader || preexistingHeaders) {
                 try {
                     xtw.writeEndElement();
+                    endedHeader = true;
                 } catch (XMLStreamException e) {
                     throw new SoapFault(
                         new org.apache.cxf.common.i18n.Message("XML_WRITE_EXC", BUNDLE),

@@ -168,6 +173,7 @@
                 }
             }
         }
+        return endedHeader;
     }       
     
     protected boolean isRequestor(Message message) {

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?view=diff&rev=472125&r1=472124&r2=472125
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Tue Nov  7 06:33:42 2006
@@ -449,18 +449,22 @@
 
         private void handleResponse() throws IOException {
             Exchange exchange = outMessage.getExchange();
-            if (exchange != null && exchange.isOneWay()) {
+            int responseCode = getResponseCode(connection);
+            if (exchange != null
+                && exchange.isOneWay()
+                && responseCode != HttpURLConnection.HTTP_ACCEPTED) {
                 //oneway operation
                 connection.getInputStream().close();
                 return;
             }
+            
             Message inMessage = new MessageImpl();
             if (exchange != null) {
                 exchange.setInMessage(inMessage);
             }
             InputStream in = null;
             inMessage.put(Message.PROTOCOL_HEADERS, connection.getHeaderFields());
-            inMessage.put(Message.RESPONSE_CODE, getResponseCode(connection));
+            inMessage.put(Message.RESPONSE_CODE, responseCode);
             if (connection instanceof HttpURLConnection) {
                 HttpURLConnection hc = (HttpURLConnection)connection;
                 in = hc.getErrorStream();

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java?view=diff&rev=472125&r1=472124&r2=472125
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
Tue Nov  7 06:33:42 2006
@@ -102,8 +102,11 @@
         }
         setupGreeter("org/apache/cxf/systest/ws/rm/anonymous.xml");
 
+        System.out.println("*** calling once");
         greeter.greetMeOneWay("once");
+        System.out.println("*** calling twice");
         greeter.greetMeOneWay("twice");
+        System.out.println("*** calling thrice");
         greeter.greetMeOneWay("thrice");
 
         // three application messages plus createSequence
@@ -115,13 +118,13 @@
         mf.verifyActions(expectedActions, true);
         mf.verifyMessageNumbers(new String[] {null, "1", "2", "3"}, true);
 
-        // createSequenceResponse plus ? partial responses
-        // partial responses not sent!
-        mf.verifyMessages(1, false);
-        expectedActions = new String[] {RMConstants.getCreateSequenceResponseAction()};
+        // createSequenceResponse plus 3 partial responses
+        
+        mf.verifyMessages(4, false);
+        expectedActions = new String[] {RMConstants.getCreateSequenceResponseAction(), null,
null, null};
         mf.verifyActions(expectedActions, false);
-        mf.verifyMessageNumbers(new String[] {null}, false);
-        mf.verifyAcknowledgements(new boolean[] {false}, false);
+        mf.verifyMessageNumbers(new String[] {null, null, null, null}, false);
+        mf.verifyAcknowledgements(new boolean[] {false, false, false, false}, false);
     }
 
     // --- test utilities ---



Mime
View raw message