servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r599749 - /servicemix/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
Date Fri, 30 Nov 2007 09:22:39 GMT
Author: ffang
Date: Fri Nov 30 01:22:27 2007
New Revision: 599749

URL: http://svn.apache.org/viewvc?rev=599749&view=rev
Log:
[SM-1158] Cxf BC provider should handle soap message correctly when soap message has empty
soap header
[SM-1159] Cxf bc provider should check MessageExchange status before send out the message
to avoid "Out not supported" exception.

Modified:
    servicemix/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java

Modified: servicemix/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java?rev=599749&r1=599748&r2=599749&view=diff
==============================================================================
--- servicemix/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
(original)
+++ servicemix/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
Fri Nov 30 01:22:27 2007
@@ -27,6 +27,7 @@
 import javax.jbi.messaging.InOut;
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.transform.Source;
@@ -42,6 +43,7 @@
 import org.apache.cxf.phase.PhaseInterceptorChain;
 import org.apache.cxf.phase.PhaseManager;
 import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.staxutils.DepthXMLStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.servicemix.JbiConstants;
@@ -79,6 +81,10 @@
 
     public void onMessage(Message message) {
         try {
+            if (messageExchange.getStatus() != ExchangeStatus.ACTIVE) {
+                return;
+            }
+
             contentType = (String) message.get(Message.CONTENT_TYPE);
             SoapMessage soapMessage = new SoapMessage(message);
 
@@ -107,11 +113,11 @@
 
             PhaseInterceptorChain inChain = inboundChainCache.get(pm
                     .getInPhases(), inList);
-            inChain.add(providerEndpoint.getOutInterceptors());
-            inChain.add(providerEndpoint.getOutFaultInterceptors());
+            inChain.add(providerEndpoint.getInInterceptors());
+            inChain.add(providerEndpoint.getInFaultInterceptors());
             soapMessage.setInterceptorChain(inChain);
             inChain.doIntercept(soapMessage);
-
+           
             if (boi.getOperationInfo().isOneWay()) {
                 messageExchange.setStatus(ExchangeStatus.DONE);
             } else if (soapMessage.get("jbiFault") != null
@@ -159,16 +165,34 @@
 
     private XMLStreamReader createXMLStreamReaderFromMessage(Message message) {
         XMLStreamReader xmlReader = null;
+        StreamSource bodySource = new StreamSource(message
+                .getContent(InputStream.class));
+        xmlReader = StaxUtils.createXMLStreamReader(bodySource);
+        
+        findBody(message, xmlReader);
+        
+        return xmlReader;
+    }
+    
+    private void findBody(Message message, XMLStreamReader xmlReader) {
+        DepthXMLStreamReader reader = new DepthXMLStreamReader(xmlReader);
         try {
-            StreamSource bodySource = new StreamSource(message
-                    .getContent(InputStream.class));
-            xmlReader = StaxUtils.createXMLStreamReader(bodySource);
-            xmlReader.nextTag();
-            xmlReader.nextTag();
-            xmlReader.nextTag();
+            int depth = reader.getDepth();
+            int event = reader.getEventType();
+            while (reader.getDepth() >= depth && reader.hasNext()) {
+                QName name = null;
+                if (event == XMLStreamReader.START_ELEMENT) {
+                    name = reader.getName();
+                }
+                if (event == XMLStreamReader.START_ELEMENT && name.equals(((SoapMessage)message).getVersion().getBody()))
{
+                    reader.nextTag();
+                    return;
+                }
+                event = reader.next();
+            }
+            return;
         } catch (XMLStreamException e) {
-            e.printStackTrace();
+            throw new RuntimeException("Couldn't parse stream.", e);
         }
-        return xmlReader;
     }
-}
\ No newline at end of file
+}



Mime
View raw message