1 10 11 package org.mule.providers.soap.xfire; 12 13 import org.codehaus.xfire.MessageContext; 14 import org.codehaus.xfire.handler.AbstractHandler; 15 import org.jdom.Element; 16 import org.jdom.Namespace; 17 import org.mule.config.MuleProperties; 18 import org.mule.providers.soap.MuleSoapHeaders; 19 import org.mule.umo.UMOEvent; 20 21 24 public class MuleHeadersOutHandler extends AbstractHandler 25 { 26 32 public void invoke(MessageContext context) throws Exception 33 { 34 UMOEvent event = (UMOEvent)context.getProperty(MuleProperties.MULE_EVENT_PROPERTY); 35 36 if (event == null && context.getClient() != null) 37 { 38 event = (UMOEvent)context.getClient().getProperty(MuleProperties.MULE_EVENT_PROPERTY); 39 } 40 41 if (event != null) 42 { 43 MuleSoapHeaders muleHeaders = new MuleSoapHeaders(event); 44 Element header = context.getOutMessage().getHeader(); 45 46 if (header == null) 47 { 48 header = new Element("Header", context.getOutMessage().getSoapVersion().getPrefix(), 49 context.getOutMessage().getSoapVersion().getNamespace()); 50 } 51 52 55 Element muleHeader = null; 56 Namespace ns = Namespace.getNamespace(MuleSoapHeaders.MULE_NAMESPACE, 57 MuleSoapHeaders.MULE_10_ACTOR); 58 if (muleHeaders.getCorrelationId() != null || muleHeaders.getReplyTo() != null) 59 { 60 muleHeader = new Element(MuleSoapHeaders.MULE_HEADER, ns); 61 } 62 else 63 { 64 return; 65 } 66 67 Element e = null; 68 if (muleHeaders.getCorrelationId() != null) 69 { 70 71 e = new Element(MuleProperties.MULE_CORRELATION_ID_PROPERTY, ns); 72 e.setText(muleHeaders.getCorrelationId()); 73 muleHeader.addContent(e); 74 75 e = new Element(MuleProperties.MULE_CORRELATION_GROUP_SIZE_PROPERTY, ns); 76 e.setText(muleHeaders.getCorrelationGroup()); 77 muleHeader.addContent(e); 78 79 e = new Element(MuleProperties.MULE_CORRELATION_SEQUENCE_PROPERTY, ns); 80 e.setText(muleHeaders.getCorrelationSequence()); 81 muleHeader.addContent(e); 82 83 } 84 if (muleHeaders.getReplyTo() != null) 85 { 86 87 e = new Element(MuleProperties.MULE_REPLY_TO_PROPERTY, ns); 88 e.setText(muleHeaders.getReplyTo()); 89 muleHeader.addContent(e); 90 } 91 header.addContent(muleHeader); 92 93 context.getOutMessage().setHeader(header); 94 } 95 } 96 } 97 | Popular Tags |