Package org.codehaus.xfire.transport

Examples of org.codehaus.xfire.transport.Channel


        String addr = epr.getAddress();
        OutMessage outMessage = null;

        boolean isFault = epr.getName().equals(WSAConstants.WSA_FAULT_TO);
        Transport t = null;
        Channel c = null;
       
        if (addr == null)
        {
            throw new XFireFault("Invalid ReplyTo address.", XFireFault.SENDER);
        }
       
        if (addr.equals(factory.getAnonymousUri()))
        {
            outMessage = new OutMessage(Channel.BACKCHANNEL_URI);
            c = context.getInMessage().getChannel();
            t = c.getTransport();
        }
        else
        {
            if (isNoneAddress(factory, addr))
            {
View Full Code Here


    public void invoke(MessageContext context)
        throws Exception
    {
        if (context.getBinding() != null) return;
       
        Channel c = context.getInMessage().getChannel();
        Service service = context.getService();
       
        if (service == null)
        {
            throw new XFireFault("Could not find a service to invoke.", XFireFault.SENDER);
        }
       
        // find a binding with that soap binding id
        // set the binding
        Binding binding =  c.getTransport().findBinding(context, service);
       
        if (binding == null)
        {
            throw new XFireFault("Could not find an appropriate Transport Binding to invoke.", XFireFault.SENDER);
        }
       
        if (!binding.isUndefinedEndpointAllowed())
        {
            boolean defined = false;
            for (Iterator itr = service.getEndpoints().iterator(); itr.hasNext();)
            {
                if (((Endpoint) itr.next()).getUrl().equals(c.getUri()))
                {
                    defined = true;
                    break;
                }
            }
View Full Code Here

            context.setService(getServiceRegistry().getService(service));

        InMessage msg = new InMessage(streamReader);

        Transport t = getXFire().getTransportManager().getTransport(LocalTransport.BINDING_ID);
        Channel c = t.createChannel();

        c.receive(context, msg);

        String response = out.toString();
        if (response == null || response.length() == 0)
            return null;
View Full Code Here

        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

        // Create a fault pipeline
        HandlerPipeline faultPipe = new HandlerPipeline(context.getXFire().getOutPhases());
       
        faultPipe.addHandlers(context.getXFire().getFaultHandlers());
       
        Channel faultChannel = context.getExchange().getFaultMessage().getChannel();
        if (faultChannel != null)
        {
            faultPipe.addHandlers(faultChannel.getTransport().getFaultHandlers());
        }

        if (context.getService() != null)
        {
            faultPipe.addHandlers(context.getService().getFaultHandlers());
View Full Code Here

       
        InputStream stream = getResourceAsStream(document);
        InMessage msg = new InMessage(STAXUtils.createXMLStreamReader(stream, "UTF-8",null));

        Transport t = getXFire().getTransportManager().getTransport(LocalTransport.BINDING_ID);
        Channel c = t.createChannel();
       
        c.receive(context, msg);
       
        String response = out.toString();
        if (response == null || response.length() == 0)
            return null;
View Full Code Here

    }

    public void invoke(MessageContext context)
        throws XFireFault
    {
        Channel faultChannel = context.getExchange().getFaultMessage().getChannel();

        try
        {
            // TODO: Check if this is a DeadLetterChannel. If its not we need to
            // try resending this message through the DeadLetterChannel.
            faultChannel.send(context, (OutMessage) context.getExchange().getFaultMessage());
        }
        catch (XFireException e)
        {
            logger.error("Could not send fault.", e);
        }
View Full Code Here

            else
            {
                // Send a response from the Channel to the client
                MessageContext oldContext = (MessageContext)context.getProperty( OLD_CONTEXT );

                Channel channel = oldContext.getOutMessage().getChannel();
                sendViaNewChannel( context, oldContext, message, channel, (String)context.getProperty( SENDER_URI ) );
            }
        }
        else
        {
            // Send a request from the channel to the service
            MessageContext receivingContext = new MessageContext();
            receivingContext.setXFire( context.getXFire() );
            receivingContext.setService( getService( context.getXFire(), message.getUri() ) );
            receivingContext.setProperty( OLD_CONTEXT, context );
            receivingContext.setProperty( SENDER_URI, getUri() );
            receivingContext.setSession( session );

            final Channel channel;
            final String uri = message.getUri();
            try
            {
                channel = getTransport().createChannel( uri );
            }
View Full Code Here

    protected Channel createNewChannel(String uri)
    {
        log.debug("Creating new channel for uri: " + uri);
       
        Channel c = new JMSChannel(uri, this);
        c.setEndpoint(new DefaultEndpoint());

        return c;
    }
View Full Code Here

    {
        response.setStatus(200);
        response.setBufferSize(1024 * 8);

        MessageContext context = createMessageContext(request, response, service);
        Channel channel = createChannel(context);
       
        String soapAction = getSoapAction(request);
        String contentType = request.getContentType();
        if (null == contentType)
        {
            response.setContentType("text/html; charset=UTF-8");
            // TODO: generate service description here
           
            response.getWriter().write("<html><body>Invalid SOAP request.</body></html>");
            response.getWriter().close();
        }
        else if (contentType.toLowerCase().indexOf("multipart/related") != -1)
        {
          // Nasty Hack to workaraound bug with lowercasing contenttype by some serwers what cause problems with finding message parts.
          // There should be better fix for this.
          String ct = request.getContentType().replaceAll("--=_part_","--=_Part_");
         
         
            Attachments atts = new StreamedAttachments(context,request.getInputStream(), ct);
         
            String encoding = getEncoding(atts.getSoapContentType());

            XMLStreamReader reader =
                STAXUtils.createXMLStreamReader(atts.getSoapMessage().getDataHandler().getInputStream(),
                                                encoding,
                                                context);
            InMessage message = new InMessage(reader, request.getRequestURI());
            message.setProperty(SoapConstants.SOAP_ACTION, soapAction);
            message.setAttachments(atts);
           
            channel.receive(context, message);
           
            try
            {
                reader.close();
            }
            catch (XMLStreamException e)
            {
                throw new XFireRuntimeException("Could not close XMLStreamReader.");
            }
        }
        else
        {
            // Remove " and ' char
            String charEncoding = request.getCharacterEncoding();
            charEncoding = dequote(charEncoding);
            XMLStreamReader reader =
                STAXUtils.createXMLStreamReader(request.getInputStream(),
                                                charEncoding,
                                                context);
           
            InMessage message = new InMessage(reader, request.getRequestURI());
            message.setProperty(SoapConstants.SOAP_ACTION, soapAction);
            channel.receive(context, message);
           
            try
            {
                reader.close();
            }
View Full Code Here

TOP

Related Classes of org.codehaus.xfire.transport.Channel

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.