camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/4] camel git commit: CAMEL-8351 - simple implementation for breadcrumbId to be set as camel exhange's header
Date Mon, 06 Mar 2017 08:52:07 GMT
CAMEL-8351 - simple implementation for breadcrumbId to be set as camel exhange's header


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a5b5deb1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a5b5deb1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a5b5deb1

Branch: refs/heads/master
Commit: a5b5deb1643dfc640ea8dd99fd9232927cb9516a
Parents: 54d932a
Author: onders86 <ondersezgin@gmail.com>
Authored: Wed Mar 1 22:22:23 2017 +0300
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Mar 6 09:50:14 2017 +0100

----------------------------------------------------------------------
 .../spring/ws/SpringWebserviceConsumer.java     | 29 +++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a5b5deb1/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java
b/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java
index 3398216..e66ab63 100644
--- a/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java
+++ b/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java
@@ -19,6 +19,8 @@ package org.apache.camel.component.spring.ws;
 import java.util.Iterator;
 import java.util.Map;
 import javax.xml.namespace.QName;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPMessage;
 import javax.xml.transform.Source;
 
 import org.apache.camel.Endpoint;
@@ -36,6 +38,7 @@ import org.springframework.ws.server.endpoint.MessageEndpoint;
 import org.springframework.ws.soap.SoapHeader;
 import org.springframework.ws.soap.SoapHeaderElement;
 import org.springframework.ws.soap.SoapMessage;
+import org.springframework.ws.soap.saaj.SaajSoapMessage;
 
 public class SpringWebserviceConsumer extends DefaultConsumer implements MessageEndpoint
{
 
@@ -54,7 +57,10 @@ public class SpringWebserviceConsumer extends DefaultConsumer implements
Message
     public void invoke(MessageContext messageContext) throws Exception {
         Exchange exchange = getEndpoint().createExchange(ExchangePattern.InOptionalOut);
         populateExchangeFromMessageContext(messageContext, exchange);
-
+        
+        // populate camel exchange with breadcrumb from transport header        
+        populateExchangeWithBreadcrumbFromMessageContext(messageContext, exchange);
+        
         // start message processing
         getProcessor().process(exchange);
 
@@ -74,6 +80,27 @@ public class SpringWebserviceConsumer extends DefaultConsumer implements
Message
         }
 
     }
+    
+    private void populateExchangeWithBreadcrumbFromMessageContext(MessageContext messageContext,
Exchange exchange) {
+        SaajSoapMessage saajSoap = (SaajSoapMessage) messageContext.getRequest();
+        SOAPMessage soapMesssageRequest = null;
+        if (saajSoap != null) {
+            soapMesssageRequest = saajSoap.getSaajMessage();
+            if (soapMesssageRequest != null) {
+                MimeHeaders mimeHeaders = soapMesssageRequest.getMimeHeaders();
+                if (mimeHeaders != null) {
+                    String[] breadcrumbIdHeaderValues = mimeHeaders.getHeader(Exchange.BREADCRUMB_ID);
+                    // expected to get one token
+                    // if more than one token expected, 
+                    // presumably breadcrumb generation strategy 
+                    // may be required to implement
+                    if (breadcrumbIdHeaderValues != null && breadcrumbIdHeaderValues.length
>= 1) {
+                        exchange.getIn().setHeader(Exchange.BREADCRUMB_ID, breadcrumbIdHeaderValues[0]);
+                    }
+                }
+            }
+        }
+    }
 
     private void populateExchangeFromMessageContext(MessageContext messageContext, Exchange
exchange) {
         populateExchangeWithPropertiesFromMessageContext(messageContext, exchange);


Mime
View raw message