Package javax.xml.ws.handler

Examples of javax.xml.ws.handler.MessageContext


    }

    public void testCreateOutputStreamContext() throws IOException {

        MessageContext messageContext = EasyMock.createMock(MessageContext.class);
        OutputStreamMessageContext ret = clientTransport.createOutputStreamContext(messageContext);
       
        assertNotNull("OutputStreamMessageContext must not be null", ret);
        assertEquals("OutputStreamMessageContext of incorrect type",
                     JBIOutputStreamMessageContext.class, ret.getClass());
View Full Code Here


        assertNotNull("response not available in context", inctx.getResponse());
    }

    public void testCreateOutputStreamContext() throws IOException {

        MessageContext mc = EasyMock.createMock(MessageContext.class);
        Response resp = EasyMock.createNiceMock(Response.class);
        resp.setStatusCode(200);
        EasyMock.expect(resp.getOutputStream()).andReturn(EasyMock.createNiceMock(OutputStream.class));
       
        EasyMock.expect(mc.get(GeronimoInputStreamMessageContext.RESPONSE))
                .andReturn(resp);
       
        EasyMock.expect(mc.get("foo")).andReturn("ret");
        EasyMock.replay(mc);
        EasyMock.replay(resp);
       
        OutputStreamMessageContext outctx = transport.createOutputStreamContext(mc);
       
View Full Code Here

        }
       
        // If on the inbound path we managed to construct a binding message
        // context use it - otherwise create a new one.

        MessageContext replyBindingCtx = bindingCtx;
        if (null == replyBindingCtx) {
            bindingCtx = binding.getBindingImpl().createBindingMessageContext(replyObjectCtx);
            replyBindingCtx = bindingCtx;
        } else if (null != replyObjectCtx) {
            replyBindingCtx.putAll(replyObjectCtx);
        }
               

        // The following will only succeed if we have a data binding callback.
       
        if (handlerInvoker.faultRaised(replyObjectCtx)) {
            LOG.fine("Marshalling fault.");
            marshalFault(replyObjectCtx, replyBindingCtx);
        } else if (null != replyObjectCtx.get(ObjectMessageContext.MESSAGE_PAYLOAD)
            || state.value() >= ServerRequestState.DISPATCHED.value()
            || null != replyObjectCtx.get(ObjectMessageContext.METHOD_RETURN)) {
            LOG.fine("Marshalling.");
            marshal(replyObjectCtx, replyBindingCtx);
        }

        // If protocol handlers were invoked inbound, then also invoke them
        // outbound - except when message is oneway.
        // TODO: relax this restriction to allow outbound processing of system
        // handlers.
        // Note we may not be able to find out if the message is oneway (in case where
        // inbound processing failed while invoking stream handlers).

        if (state.value() >= ServerRequestState.PROTOCOL_HANDLERS_INVOKED.value() && !isOneway()) {

            // Protocol and runtime exceptions have already been caught by
            // handler invoker and stored in binding context
            // As marshalling took place prior to invoking the
            // protocol handlers we need to go back and marshal this fault.
           
            handlerInvoker.invokeProtocolHandlers(isRequestor(), replyBindingCtx);
           
            if (handlerInvoker.faultRaised(replyBindingCtx)
                && !binding.getBindingImpl().hasFault(replyBindingCtx)) {
                LOG.fine("Marshalling fault raised by protocol handlers.");
                replyObjectCtx.setException((Exception)replyBindingCtx.get(
                    ObjectMessageContext.METHOD_FAULT));
                marshalFault(replyObjectCtx, replyBindingCtx);
            }
        }
View Full Code Here

    public MessageContext getWrappedContext() {
        return context;
    }
   
    public static MessageContext unwrap(MessageContext ctx) {
        MessageContext wrapper = ctx;
        while (wrapper instanceof MessageContextWrapper) {
            wrapper = ((MessageContextWrapper)wrapper).getWrappedContext();
        }
        return wrapper;
    }
View Full Code Here

        WebServiceContextImpl wsci = new WebServiceContextImpl();
        assertNull(wsci.getMessageContext());

       
        final MessageContext ctx = new GenericMessageContext();
        WebServiceContextImpl.setMessageContext(ctx);

        assertSame(ctx, wsci.getMessageContext());

        Thread t = new Thread() {
                public void run() {
                    WebServiceContextImpl threadLocalWSCI = new WebServiceContextImpl();

                    assertNull(threadLocalWSCI.getMessageContext());

                    MessageContext threadLocalCtx = new GenericMessageContext();
                    WebServiceContextImpl.setMessageContext(threadLocalCtx);


                    assertSame(threadLocalCtx, threadLocalWSCI.getMessageContext());
                    assertTrue(ctx !=  threadLocalWSCI.getMessageContext());
View Full Code Here

    public HandlerInvoker createHandlerInvoker() {
        return new HandlerChainInvoker(getHandlerChain(true));
    }
   
    public MessageContext createBindingMessageContext(MessageContext orig) {
        MessageContext bindingCtx = new GenericMessageContext();
        if (null != orig) {
            bindingCtx.putAll(orig);
        }
        return bindingCtx;
    }
View Full Code Here

                        (JMSOutputStreamContext)transport.createOutputStreamContext(ctx);
                    octx.setOneWay(true);
                    transport.finalPrepareOutputStreamContext(octx);
                    serverRcvdInOneWayCall = new String(bytes);

                    MessageContext replyCtx = new GenericMessageContext();
                    ctx.put("ObjectMessageContext.MESSAGE_INPUT", Boolean.TRUE);
                    replyCtx.putAll(ctx);
                    replyCtx.put("ObjectMessageContext.MESSAGE_INPUT", Boolean.TRUE);

                    ((JMSServerTransport)transport).postDispatch(replyCtx, octx);
                    octx.getOutputStream().close();
                } catch (Exception ex) {
                    ex.printStackTrace();
View Full Code Here

                octx.setOneWay(false);
                transport.finalPrepareOutputStreamContext(octx);
                octx.getOutputStream().write(bytes, 0, total);
                octx.getOutputStream().flush();

                MessageContext replyCtx = new GenericMessageContext();
                ctx.put("ObjectMessageContext.MESSAGE_INPUT", Boolean.TRUE);
                replyCtx.putAll(ctx);
                replyCtx.put("ObjectMessageContext.MESSAGE_INPUT", Boolean.TRUE);

                ((JMSServerTransport)transport).postDispatch(replyCtx, octx);
                octx.getOutputStream().close();
            } catch (Exception ex) {
             //
View Full Code Here

                octx.setOneWay(false);
                transport.finalPrepareOutputStreamContext(octx);
                octx.getOutputStream().write(bytes, 0, total);
                octx.getOutputStream().flush();

                MessageContext replyCtx = new GenericMessageContext();
                ctx.put("ObjectMessageContext.MESSAGE_INPUT", Boolean.TRUE);
                replyCtx.putAll(ctx);
                replyCtx.put("ObjectMessageContext.MESSAGE_INPUT", Boolean.TRUE);

                ((JMSServerTransport)transport).postDispatch(replyCtx, octx);
                octx.getOutputStream().close();
            } catch (Exception ex) {
             //
View Full Code Here

                //ignore
            }
            me = me.substring("PauseForTwoSecs".length()).trim();
        }

        MessageContext mc = wsContext.getMessageContext();
        JMSMessageHeadersType headers =
            (JMSMessageHeadersType) mc.get(JMSConstants.JMS_SERVER_REQUEST_HEADERS);
        System.out.println("get the message headers JMSCorrelationID: " + headers.getJMSCorrelationID());
        System.out.println("Reached here :" + me);
       
        // set reply header custom property
        JMSPropertyType testProperty = new JMSPropertyType();
        testProperty.setName("Test_Prop");
        testProperty.setValue("some return value "  + me);
       
        System.out.println("found property in request headers at index: "
                           + headers.getProperty().indexOf(testProperty));
       
        JMSMessageHeadersType responseHeaders =
            (JMSMessageHeadersType) mc.get(JMSConstants.JMS_SERVER_RESPONSE_HEADERS);
        responseHeaders.getProperty().add(testProperty);
       
        return "Hello " + me;
    }
View Full Code Here

TOP

Related Classes of javax.xml.ws.handler.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.