Package javax.xml.ws

Examples of javax.xml.ws.LogicalMessage


                super.handleFault(ctx);
                try {
                    Boolean outbound = (Boolean)
                        ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
                    if (!outbound) {
                        LogicalMessage msg = ctx.getMessage();
                        String payload = convertDOMToString(msg.getPayload());
                        assertTrue(payload.indexOf(
                            "<faultstring>"
                            + "servant throws SOAPFaultException"
                            + "</faultstring>") > -1);
                    }
View Full Code Here


            public boolean handleFault(LogicalMessageContext messageContext) {
                return true;
            }

            public boolean handleMessage(LogicalMessageContext messageContext) {
                LogicalMessage msg = messageContext.getMessage();
                AddNumbersResponse resp = new AddNumbersResponse();
                resp.setReturn(11);
                msg.setPayload(resp, null);
                return false;
            }
        });
        HandlerChainInvoker invoker1 = new HandlerChainInvoker(list);
View Full Code Here

    public final boolean handleMessage(LogicalMessageContext messageContext) {
        //System.out.println("LogicalMessageHandler handleMessage called");

        try {
            // get the LogicalMessage from our context
            LogicalMessage msg = messageContext.getMessage();

            // check the payload, if its an AddNumbers request, we'll intervene
            JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
            Object payload = msg.getPayload(jaxbContext);
            Object value = payload;
            if (payload instanceof JAXBElement) {
                value = ((JAXBElement)payload).getValue();
            }

            if (value instanceof AddNumbers) {
                AddNumbers req = (AddNumbers)value;

                int a = req.getArg0();
                req.setArg0(a * 10);
                msg.setPayload(payload, jaxbContext);
            }
            return true;
        } catch (JAXBException ex) {
            throw new ProtocolException(ex);
        }
View Full Code Here

            boolean outbound = (Boolean)messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

            if (outbound) {
                // get the LogicalMessage from our context
                //
                LogicalMessage msg = messageContext.getMessage();

                // check the payload, if its an AddNumbers request, we'll intervene
                //
                JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
                Object payload = msg.getPayload(jaxbContext);
                if (payload instanceof JAXBElement) {
                    payload = ((JAXBElement)payload).getValue();
                }

                if (payload instanceof AddNumbers) {
                    AddNumbers req = (AddNumbers)payload;

                    // now, if the arguments are small, let's do the calculation here
                    //
                    int a = req.getArg0();
                    int b = req.getArg1();

                    if (isSmall(a) && isSmall(b)) {
                        int answer = a + b;

                        //System.out.printf("SmallNumberHandler addNumbers(%d, %d) == %d\n", a, b, answer);
                        // ok, we've done the calculation, so build the
                        // response and set it as the payload of the message

                        AddNumbersResponse resp = new AddNumbersResponse();
                        resp.setReturn(answer);
                        msg.setPayload(new ObjectFactory().createAddNumbersResponse(resp),
                                       jaxbContext);

                        Source src = msg.getPayload();
                        msg.setPayload(src);

                        payload = msg.getPayload(jaxbContext);
                        if (payload instanceof JAXBElement) {
                            payload = ((JAXBElement)payload).getValue();
                        }

                        AddNumbersResponse resp2 = (AddNumbersResponse)payload;
View Full Code Here

     */
    public void testInboundFaultFlow() throws Exception {
        MessageContext mc = createSampleFaultMessageContext();
       
        LogicalMessageContext lmc = MessageContextFactory.createLogicalMessageContext(mc);
        LogicalMessage lm = lmc.getMessage();
        Source payload = lm.getPayload();
        assertTrue("The returned payload (Source) was null", payload != null);
       
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        StreamResult result = new StreamResult(baos);
        Transformer t = TransformerFactory.newInstance().newTransformer();
View Full Code Here

        assertTrue("The returned SOAPMessage was null", sm != null);
        assertTrue("The SOAPMessage did not contain a SOAPBody", sm.getSOAPBody() != null);
        assertTrue("The SOAPBody did not contain a SOAPFault", sm.getSOAPBody().getFault() != null);
       
        LogicalMessageContext lmc = MessageContextFactory.createLogicalMessageContext(mc);
        LogicalMessage lm = lmc.getMessage();
        Source payload = lm.getPayload();
        assertTrue("The returned payload (Source) was null", payload != null);
       
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        StreamResult result = new StreamResult(baos);
        Transformer t = TransformerFactory.newInstance().newTransformer();
View Full Code Here

     * @throws Exception
     */
    public void testGetPayloadAsSource() 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);
        assertTrue("The content returned was incomplete, unexpected element", resultContent.indexOf("echoString") > -1);
View Full Code Here

     * @throws Exception
     */
    public void testGetAndSetPayloadAsSource() 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);
        assertTrue("The content returned was incorrect", resultContent.indexOf(INPUT) > 0);

        // Now manipluate the content and set it back on the message.
        int start = resultContent.indexOf(INPUT);
        int end = start + INPUT.length();
       
        String newInput = "new content goes here";
        String newContent = resultContent.substring(0, start) + newInput + resultContent.substring(end);
       
        ByteArrayInputStream bais = new ByteArrayInputStream(newContent.getBytes());
        StreamSource newPayload = new StreamSource(bais);
       
        msg.setPayload(newPayload);
       
        // Check the payload to make sure the new content that we added
        // was insterted correctly.
        Source payload2 = msg.getPayload();
        assertTrue("The returned payload (Source) was null", payload2 != null);
       
        String resultContent2 = _getStringFromSource(payload2);
        assertTrue("The updated content returned was null", resultContent2 != null);
        assertTrue("The updated content returned was incorrect, old content found", resultContent2.indexOf(INPUT) < 0);
View Full Code Here

     * @throws Exception
     */
    public void testGetMultiplePayloadsAsSource() throws Exception {
        LogicalMessageContext lmc = createSampleContext();

        LogicalMessage msg = lmc.getMessage();
        assertTrue("The returned LogicalMessage was null", msg != null);

        int loopCount = 3;
        for (int i = 0; i < loopCount; ++i) {
            Source payload = msg.getPayload();
            assertTrue("Attempt number "  + i + " to get the payload (Source) was null", payload != null);


            String resultContent = _getStringFromSource(payload);
            assertTrue("The content returned in loop " + i + " was null", resultContent != null);
View Full Code Here

     * @throws Exception
     */
    public void testGetAndSetFaultPayloadAsSource() throws Exception {
        LogicalMessageContext lmc = createSampleFaultContext();
       
        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);
        assertTrue("The content returned was incorrect", resultContent.indexOf(FAULT_INPUT) > 0);
        assertTrue("The content returned was incorrect, no fault found", resultContent.indexOf("Fault") > 0);
       
        // Now manipluate the content and set it back on the message.
        int start = resultContent.indexOf(FAULT_INPUT);
        int end = start + FAULT_INPUT.length();
       
        String newFaultInput = "new fault content goes here";
        String newContent = resultContent.substring(0, start) + newFaultInput + resultContent.substring(end);
       
        ByteArrayInputStream bais = new ByteArrayInputStream(newContent.getBytes());
        StreamSource newPayload = new StreamSource(bais);
       
        msg.setPayload(newPayload);
       
        // Check the payload to make sure the new content that we added
        // was insterted correctly.
        Source payload2 = msg.getPayload();
        assertTrue("The returned payload (Source) was null", payload2 != null);
       
        String resultContent2 = _getStringFromSource(payload2);
        assertTrue("The updated content returned was null", resultContent2 != null);
        assertTrue("The updated content returned was incorrect, old content found", resultContent2.indexOf(FAULT_INPUT) < 0);
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.