Package javax.xml.ws

Examples of javax.xml.ws.LogicalMessage


     * @throws Exception
     */
    public void testGetPayloadAsJAXB() throws Exception {
        LogicalMessageContext lmc = createSampleContext();
               
        LogicalMessage msg = lmc.getMessage();
        assertTrue("The returned LogicalMessage was null", msg != null);
       
        JAXBContext jbc = JAXBContext.newInstance("test");
       
        Object obj = msg.getPayload(jbc);
        assertTrue("The returned payload (Object) was null", obj != null);
        assertTrue("The returned payload (Object) was of the wrong type: " + obj.getClass().getName(), obj.getClass().equals(EchoString.class));
       
        EchoString echo = (EchoString) obj;
        assertTrue("The EchoString object had null input", echo.getInput() != null);
View Full Code Here


   
   
    public void testConvertMessageToFault() throws Exception {
        LogicalMessageContext lmc = createSampleContext();
        LogicalMessage msg = lmc.getMessage();
        assertTrue("The returned LogicalMessage was null", msg != null);

        Source payload = msg.getPayload();
        assertTrue("The returned payload (Source) was null", payload != null);

        String resultContent = _getStringFromSource(payload);
        assertTrue("The content returned was null", resultContent != null);
       
        ByteArrayInputStream bais = new ByteArrayInputStream(sampleSOAP11FaultPayload.getBytes());
        StreamSource faultSource = new StreamSource(bais);
       
        msg.setPayload(faultSource);
       
        Source newFaultSource = msg.getPayload();
        assertTrue("The new fault content returned was null", faultSource != null);
       
        String newFaultContent = _getStringFromSource(newFaultSource);
        assertTrue("The new fault content returned was invalid", newFaultContent.equals(sampleSOAP11FaultPayload));
    }
View Full Code Here

    }

    public boolean handleFault(LogicalMessageContext messagecontext) {
        Boolean outbound = (Boolean)messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
        if (outbound) {  // outbound response if we're on the server
            LogicalMessage msg = messagecontext.getMessage();
            String st = getStringFromSourcePayload(msg.getPayload());
            st = st.replaceFirst("blarg", "AddNumbersLogicalHandler2 was here");
            st = st.replaceFirst("I don't like the value 99", "AddNumbersLogicalHandler2 was here");
            msg.setPayload(new StreamSource(new ByteArrayInputStream(st.getBytes())));
        }
        return true;
    }
View Full Code Here

     * manipulating the SOAP message.
     */
    public boolean handleMessage(LogicalMessageContext messagecontext) {
        Boolean outbound = (Boolean)messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
        if (!outbound) {  // inbound request if we're on the server
            LogicalMessage msg = messagecontext.getMessage();
            String st = getStringFromSourcePayload(msg.getPayload());
            if (st.contains("<arg0>99</arg0>")) {
                throw new ProtocolException("I don't like the value 99");
            }
            String txt = String.valueOf(Integer.valueOf(getFirstArg(st)) - 1);
            st = replaceFirstArg(st, txt);
            msg.setPayload(new StreamSource(new StringBufferInputStream(st)));
           
            messagecontext.put("AddNumbersLogicalHandlerInboundAppScopedProperty", "blargval");
            messagecontext.setScope("AddNumbersLogicalHandlerInboundAppScopedProperty",
                                    Scope.APPLICATION);
            messagecontext.put("AddNumbersLogicalHandlerInboundHandlerScopedProperty",
                               "blargval");
           
            // Check for the presences of the attachment property
            String propKey = MessageContext.INBOUND_MESSAGE_ATTACHMENTS;
            Map map = (Map) messagecontext.get(propKey);
            if (map == null) {
                throw new RuntimeException("Property " + propKey + " was null");
            }
            if (!(map instanceof AttachmentsAdapter)) {
                throw new RuntimeException("Expected AttachmentAddapter for Property " +
                                           propKey);
            }

        } else { // outbound response if we're on the server
            LogicalMessage msg = messagecontext.getMessage();
            String st = getStringFromSourcePayload(msg.getPayload());
            String txt = String.valueOf(Integer.valueOf(getFirstArg(st)) - deduction);
            st = replaceFirstArg(st, txt);
            msg.setPayload(new StreamSource(new StringBufferInputStream(st)));
           
            // Check for the presences of the attachment property
            String propKey = MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS;
            Map map = (Map) messagecontext.get(propKey);
            if (map == null) {
View Full Code Here

    }

    public boolean handleMessage(LogicalMessageContext messagecontext) {
        Boolean outbound = (Boolean)messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
        if (outbound) {  // outbound request on the client
            LogicalMessage msg = messagecontext.getMessage();
            Source payload = msg.getPayload();
            String st = getStringFromSourcePayload(payload);
            String txt = String.valueOf(Integer.valueOf(getFirstArg(st)) * 2);
            st = replaceFirstArg(st, txt);
            msg.setPayload(new StreamSource(new StringBufferInputStream(st)));
        }
        return true;
    }
View Full Code Here

            myClientVal = (String)messagecontext.get(propKey);
            if (myClientVal == null) {
                throw new RuntimeException("Property " + propKey + " was null.  " +
                                "MEPContext is not searching hard enough for the property.");
            }
            LogicalMessage msg = messagecontext.getMessage();
            String st = getStringFromSourcePayload(msg.getPayload());
            String txt = String.valueOf(Integer.valueOf(getFirstArg(st)) - 1);
            st = replaceFirstArg(st, txt);
            msg.setPayload(new StreamSource(new StringBufferInputStream(st)));
        }
        else {
            LogicalMessage msg = messagecontext.getMessage();
           
            Source s = msg.getPayload();
            s = msg.getPayload();
           
            String st = getStringFromSourcePayload(msg.getPayload());
            if (st.contains("<arg0>99</arg0>")) {
                throw new ProtocolException("I don't like the value 99");
            }
           
            // Check for the presences of the attachment property
View Full Code Here

        // TODO Auto-generated method stub       
    }

    public boolean handleFault(LogicalMessageContext messagecontext) {
        // let's see if we can do this
        LogicalMessage lm = messagecontext.getMessage();
        String s = getStringFromSourcePayload(lm.getPayload());
        return false;
    }
View Full Code Here

            public boolean handleMessage(LogicalMessageContext ctx) {
                super.handleMessage(ctx);
                try {
                    Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
                    if (!outbound) {
                        LogicalMessage msg = ctx.getMessage();
                        Source source = msg.getPayload();
                        assertNotNull(source);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    fail(e.toString());
View Full Code Here

            public boolean handleMessage(LogicalMessageContext ctx) {
                super.handleMessage(ctx);
                try {
                    Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
                    if (outbound) {
                        LogicalMessage msg = ctx.getMessage();
                        assertNotNull("logical message is null", msg);
                        JAXBContext jaxbCtx = JAXBContext.newInstance(PackageUtils
                            .getPackageName(PingOneWay.class));
                        PingResponse resp = new PingResponse();
                        resp.getHandlersInfo().add(clientHandlerMessage);

                        msg.setPayload(resp, jaxbCtx);
                        return false;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    fail(e.toString());
View Full Code Here

            public boolean handleMessage(LogicalMessageContext ctx) {
                super.handleMessage(ctx);
                try {
                    Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
                    if (outbound) {
                        LogicalMessage msg = ctx.getMessage();
                        assertNotNull("logical message is null", msg);
                        JAXBContext jaxbCtx = JAXBContext.newInstance(PackageUtils
                            .getPackageName(PingOneWay.class));
                        PingResponse resp = new PingResponse();
                        resp.getHandlersInfo().add(clientHandlerMessage);

                        msg.setPayload(resp, jaxbCtx);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                    fail(e.toString());
View Full Code Here

TOP

Related Classes of javax.xml.ws.LogicalMessage

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.