1 18 package org.apache.axis2.transport.local; 19 20 import org.apache.axis2.Constants; 21 import org.apache.axis2.addressing.EndpointReference; 22 import org.apache.axis2.context.ConfigurationContext; 23 import org.apache.axis2.context.MessageContext; 24 import org.apache.axis2.description.TransportInDescription; 25 import org.apache.axis2.description.TransportOutDescription; 26 import org.apache.axis2.engine.AxisEngine; 27 import org.apache.axis2.engine.AxisFault; 28 import org.apache.axis2.om.impl.llom.builder.StAXBuilder; 29 import org.apache.axis2.soap.SOAPEnvelope; 30 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder; 31 32 import javax.xml.namespace.QName ; 33 import javax.xml.stream.FactoryConfigurationError; 34 import javax.xml.stream.XMLInputFactory; 35 import javax.xml.stream.XMLStreamException; 36 import javax.xml.stream.XMLStreamReader; 37 import java.io.BufferedReader ; 38 import java.io.InputStream ; 39 import java.io.InputStreamReader ; 40 41 public class LocalTransportReceiver { 42 public static ConfigurationContext CONFIG_CONTEXT; 43 44 private ConfigurationContext confContext; 45 public LocalTransportReceiver(ConfigurationContext configContext) { 46 confContext = configContext; 47 } 48 49 public LocalTransportReceiver() { 50 this(CONFIG_CONTEXT); 51 } 52 53 public void processMessage(InputStream in, EndpointReference to) throws AxisFault { 54 try { 55 TransportInDescription tIn = 56 confContext.getAxisConfiguration().getTransportIn( 57 new QName (Constants.TRANSPORT_LOCAL)); 58 TransportOutDescription tOut = 59 confContext.getAxisConfiguration().getTransportOut( 60 new QName (Constants.TRANSPORT_LOCAL)); 61 MessageContext msgCtx = new MessageContext(confContext, tIn, tOut); 62 msgCtx.setTo(to); 63 msgCtx.setServerSide(true); 64 65 XMLStreamReader reader = 66 XMLInputFactory.newInstance().createXMLStreamReader( 67 new BufferedReader (new InputStreamReader (in))); 68 69 StAXBuilder builder = new StAXSOAPModelBuilder(reader); 70 msgCtx.setEnvelope((SOAPEnvelope) builder.getDocumentElement()); 71 AxisEngine engine = new AxisEngine(confContext); 72 engine.receive(msgCtx); 73 } catch (XMLStreamException e) { 74 throw new AxisFault(e); 75 } catch (FactoryConfigurationError e) { 76 throw new AxisFault(e); 77 } 78 } 79 80 } 81 | Popular Tags |