Package org.codehaus.xfire

Examples of org.codehaus.xfire.MessageContext


        XFire xfire = endpoint.getXFire();
        Service service = endpoint.getXFireService();
        Transport t = xfire.getTransportManager().getTransport(JbiTransport.JBI_BINDING);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Channel c = t.createChannel();
        MessageContext ctx = new MessageContext();
        ctx.setXFire(xfire);
        ctx.setService(service);
        ctx.setProperty(Channel.BACKCHANNEL_URI, out);
        ctx.setExchange(new org.codehaus.xfire.exchange.MessageExchange(ctx));
        InMessage msg = new InMessage();
        ctx.getExchange().setInMessage(msg);
        if (exchange.getOperation() != null) {
            OperationInfo op = service.getServiceInfo().getOperation(exchange.getOperation().getLocalPart());
            if (op != null) {
                ctx.getExchange().setOperation(op);
            }
        }
        ctx.setCurrentMessage(msg);
        NormalizedMessage in = exchange.getMessage("in");
        msg.setXMLStreamReader(getXMLStreamReader(in.getContent()));
        if (in.getAttachmentNames() != null && in.getAttachmentNames().size() > 0) {
            JavaMailAttachments attachments = new JavaMailAttachments();
            for (Iterator it = in.getAttachmentNames().iterator(); it.hasNext();) {
                String name = (String) it.next();
                DataHandler dh = in.getAttachment(name);
                attachments.addPart(new SimpleAttachment(name, dh));
            }
            msg.setAttachments(attachments);
        }
        c.receive(ctx, msg);
        c.close();
       
        // Set response or DONE status
        if (isInAndOut(exchange)) {
            if (ctx.getExchange().hasFaultMessage() && ctx.getExchange().getFaultMessage().getBody() != null) {
                Fault fault = exchange.createFault();
                fault.setContent(new StringSource(out.toString()));
                exchange.setFault(fault);
            } else {
                NormalizedMessage outMsg = exchange.createMessage();
View Full Code Here


        if (reader == null) {
            throw new JBIException("Could not get source as XMLStreamReader.");
        }
       
        InMessage in = new InMessage(reader, "");
        MessageContext context = new MessageContext();
        context.setXFire(xfire);
        context.setService(xfire.getServiceRegistry().getService(getService().getLocalPart()));

        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        context.setProperty(Channel.BACKCHANNEL_URI, buffer);
       
        Transport transport =  xfire.getTransportManager().getTransport(LocalTransport.BINDING_ID);
        Channel channel = transport.createChannel();
        channel.receive(context, in);

        NormalizedMessage outMessage = messageExchange.createMessage();

        marshaler.setContent(outMessage, buffer.toString());
        marshaler.toNMS(outMessage, context.getOutMessage());

        answer(messageExchange, outMessage);
    }
View Full Code Here

        if (reader == null) {
            throw new JBIException("Could not get source as XMLStreamReader.");
        }

        InMessage in = new InMessage(reader, "");
        MessageContext context = new MessageContext();
        context.setXFire(xfire);
        context.setService(xfire.getServiceRegistry().getService(getService().getLocalPart()));

        Transport transport = xfire.getTransportManager().getTransport(LocalTransport.BINDING_ID);
        Channel channel = transport.createChannel();
        channel.receive(context, in);
View Full Code Here

        if (reader == null) {
            throw new JBIException("Could not get source as XMLStreamReader.");
        }
       
        InMessage in = new InMessage(reader, "");
        MessageContext context = new MessageContext();
        context.setXFire(xfire);
        context.setService(xfire.getServiceRegistry().getService(getService().getLocalPart()));

        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        context.setProperty(Channel.BACKCHANNEL_URI, buffer);
       
        Transport transport =  xfire.getTransportManager().getTransport(LocalTransport.BINDING_ID);
        Channel channel = transport.createChannel();
        channel.receive(context, in);

        NormalizedMessage outMessage = messageExchange.createMessage();

        marshaler.setContent(outMessage, buffer.toString());
        marshaler.toNMS(outMessage, context.getOutMessage());

        answer(messageExchange, outMessage);
    }
View Full Code Here

        if (reader == null) {
            throw new JBIException("Could not get source as XMLStreamReader.");
        }

        InMessage in = new InMessage(reader, "");
        MessageContext context = new MessageContext();
        context.setXFire(xfire);
        context.setService(xfire.getServiceRegistry().getService(getService().getLocalPart()));

        Transport transport = xfire.getTransportManager().getTransport(LocalTransport.BINDING_ID);
        Channel channel = transport.createChannel();
        channel.receive(context, in);
View Full Code Here

        XFire xfire = endpoint.getXFire();
        Service service = endpoint.getXFireService();
        Transport t = xfire.getTransportManager().getTransport(JbiTransport.JBI_BINDING);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Channel c = t.createChannel();
        MessageContext ctx = new MessageContext();
        ctx.setXFire(xfire);
        ctx.setService(service);
        ctx.setProperty(Channel.BACKCHANNEL_URI, out);
        ctx.setExchange(new org.codehaus.xfire.exchange.MessageExchange(ctx));
        InMessage msg = new InMessage();
        ctx.getExchange().setInMessage(msg);
        if (exchange.getOperation() != null) {
            OperationInfo op = service.getServiceInfo().getOperation(exchange.getOperation().getLocalPart());
            if (op != null) {
                ctx.getExchange().setOperation(op);
            }
        }
        ctx.setCurrentMessage(msg);
        NormalizedMessage in = exchange.getMessage("in");
        msg.setXMLStreamReader(getXMLStreamReader(in.getContent()));
        if (in.getAttachmentNames() != null && in.getAttachmentNames().size() > 0) {
            JavaMailAttachments attachments = new JavaMailAttachments();
            for (Iterator it = in.getAttachmentNames().iterator(); it.hasNext();) {
                String name = (String) it.next();
                DataHandler dh = in.getAttachment(name);
                attachments.addPart(new SimpleAttachment(name, dh));
            }
            msg.setAttachments(attachments);
        }
        EndpointDeliveryChannel.setEndpoint(endpoint);
        JBIContext.setMessageExchange(exchange);
        if (isInAndOut(exchange)) {
           
        }
        try {
            c.receive(ctx, msg);
        } finally {
            JBIContext.setMessageExchange(null);
            EndpointDeliveryChannel.setEndpoint(null);
        }
        c.close();
       
        // Set response or DONE status
        if (isInAndOut(exchange)) {
            if (ctx.getExchange().hasFaultMessage() && ctx.getExchange().getFaultMessage().getBody() != null) {
                String charSet = ctx.getExchange().getFaultMessage().getEncoding();
                Fault fault = exchange.getFault();
                if (fault == null) {
                    fault = exchange.createFault();
                    exchange.setFault(fault);
                }
                fault.setContent(new StringSource(out.toString(charSet)));
                XFireFault xFault = (XFireFault) ctx.getExchange().getFaultMessage().getBody();
                fault.setProperty(SOAP_FAULT_CODE, xFault.getFaultCode());
                fault.setProperty(SOAP_FAULT_REASON, xFault.getReason());
                fault.setProperty(SOAP_FAULT_ROLE, xFault.getRole());
                fault.setProperty(SOAP_FAULT_SUBCODE, xFault.getSubCode());
            } else {
                String charSet = ctx.getOutMessage().getEncoding();
                NormalizedMessage outMsg = exchange.getMessage("out");
                if (outMsg == null) {
                    outMsg = exchange.createMessage();
                    exchange.setMessage(outMsg, "out");
                }
                Attachments attachments = ctx.getCurrentMessage().getAttachments();
                if (attachments != null) {
                    for (Iterator it = attachments.getParts(); it.hasNext();) {
                        Attachment att = (Attachment) it.next();
                        outMsg.addAttachment(att.getId(), att.getDataHandler());
                    }
View Full Code Here

        String serviceName = to.substring(to.indexOf('/')+1);
        Service service = xfire.getServiceRegistry().getService(serviceName);
       
        InMessage message = new InMessage(new JDOMStreamReader(soapPacket.getDocument().getRootElement()), to);

        MessageContext context = new MessageContext();
        context.setProperty(PACKET, packet);
        context.setXFire(xfire);
        context.setService(service);
       
        channel.receive(context, message);
    }
View Full Code Here

     */
    protected Document invokeService(String service, XMLStreamReader streamReader)
        throws Exception
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        MessageContext context = new MessageContext();
        context.setSession(session);
        context.setXFire(getXFire());
        context.setProperty(Channel.BACKCHANNEL_URI, out);

        if (service != null)
            context.setService(getServiceRegistry().getService(service));

        InMessage msg = new InMessage(streamReader);

        Transport t = getXFire().getTransportManager().getTransport(LocalTransport.BINDING_ID);
        Channel c = t.createChannel();
View Full Code Here

    protected InMessage invokeService(OutMessage msg, String transportID)
        throws Exception
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        MessageContext context = new MessageContext();
        context.setXFire(getXFire());
        context.setProperty(Channel.BACKCHANNEL_URI, out);

        Transport t = getTransportManager().getTransport(transportID);
        Channel c = t.createChannel();
        msg.setChannel(c);

        msg.setSerializer(new CopySerializer());

        c.setEndpoint(new ChannelEndpoint()
        {
            public void onReceive(MessageContext context, InMessage msg)
            {
                try
                {
                    // force attachment read...
                    if (msg.getAttachments() != null)
                        msg.getAttachments().getParts();

                    Document doc = new StaxBuilder().build(msg.getXMLStreamReader());
                    context.setExchange(new MessageExchange(context));
                    context.getExchange().setInMessage(msg);

                    msg.setProperty(RESPONSE, doc);
                }
                catch (XMLStreamException e)
                {
                    e.printStackTrace();
                }
            }
        });

        c.send(context, msg);

        return context.getInMessage();
    }
View Full Code Here

            if (binding instanceof Soap11Binding)
                msg.setSoapVersion(Soap11.getInstance());
            else if (binding instanceof Soap12Binding)
                msg.setSoapVersion(Soap12.getInstance());
           
            context = new MessageContext();
            context.setService(client.getService());
            context.setXFire(client.getXFire());
            context.setBinding(binding);
            context.setProperty(Client.CLIENT_MODE, Boolean.TRUE);
            context.setClient(client);
View Full Code Here

TOP

Related Classes of org.codehaus.xfire.MessageContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.