Package javax.xml.ws.handler

Examples of javax.xml.ws.handler.LogicalMessageContext


   private boolean appendHandlerName(MessageContext msgContext, String direction)
   {
      try
      {
         // Get the payload as Source
         LogicalMessageContext logicalContext = (LogicalMessageContext)msgContext;
         JAXBContext jaxb = JAXBContext.newInstance(Echo.class.getPackage().getName());
         Object payload = logicalContext.getMessage().getPayload(jaxb);

         JAXBElement jaxbElement = null;
         if (payload instanceof JAXBElement)
         {
            jaxbElement = (JAXBElement)payload;
            payload = jaxbElement.getValue();
         }

         if (payload instanceof Echo)
         {
            Echo echo = (Echo)payload;
            String value = echo.getString1();
            echo.setString1(value + ":" + direction + ":LogicalJAXBHandler");
         }
         else if (payload instanceof EchoResponse)
         {
            EchoResponse echo = (EchoResponse)payload;
            String value = echo.getResult();
            echo.setResult(value + ":" + direction + ":LogicalJAXBHandler");
         }
         else
         {
            throw new WebServiceException("Invalid payload type: " + payload);
         }

         if (jaxbElement != null)
         {
            jaxbElement.setValue(payload);
            payload = jaxbElement;
         }

         // Set the updated payload
         logicalContext.getMessage().setPayload(payload, jaxb);

         return true;
      }
      catch (RuntimeException rte)
      {
View Full Code Here


   public boolean appendHandlerName(MessageContext msgContext, String direction)
   {
      try
      {
         // Get the payload as Source
         LogicalMessageContext logicalContext = (LogicalMessageContext)msgContext;
         Source source = logicalContext.getMessage().getPayload();
         TransformerFactory tf = TransformerFactory.newInstance();
         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
         tf.newTransformer().transform(source, new StreamResult(baos));

         // Parse the payload and extract the value
         Element root = DOMUtils.parse(new ByteArrayInputStream(baos.toByteArray()));

         String oldValue = DOMUtils.getTextContent(root);
         String newValue = oldValue + ":" + direction + "LogicalHandler";
         root.setTextContent(newValue);

         log.debug("oldValue: " + oldValue);
         log.debug("newValue: " + newValue);

         // Set the updated payload
         source = new DOMSource(root);
         logicalContext.getMessage().setPayload(source);

         return true;
      }
      catch (RuntimeException rte)
      {
View Full Code Here

   public boolean appendHandlerName(MessageContext msgContext, String direction)
   {
      try
      {
         // Get the payload as Source
         LogicalMessageContext logicalContext = (LogicalMessageContext)msgContext;
         Source source = logicalContext.getMessage().getPayload();
         TransformerFactory tf = TransformerFactory.newInstance();
         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
         tf.newTransformer().transform(source, new StreamResult(baos));

         // Parse the payload and extract the value
         Element root = DOMUtils.parse(new ByteArrayInputStream(baos.toByteArray()));

         String oldValue = DOMUtils.getTextContent(root);
         String newValue = oldValue + ":" + direction + ":LogicalSourceHandler";
         root.setTextContent(newValue);

         log.debug("oldValue: " + oldValue);
         log.debug("newValue: " + newValue);

         // Set the updated payload
         source = new DOMSource(root);
         logicalContext.getMessage().setPayload(source);

         return true;
      }
      catch (RuntimeException rte)
      {
View Full Code Here

    /**
     * Test the javax.xml.transform.Source based APIs on the LogicalMessage interface.
     * @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);
       
View Full Code Here

    /**
     * Tests the setting of the payload and make sure we don't cache improperly.
     * @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);
       
View Full Code Here

    /**
     * Test to make sure we can get the payload multiple times from the same LogicalMessage.
     * @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();
View Full Code Here

    /**
     * Tests the setting of the payload when the original content is a fault.
     * @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);
       
View Full Code Here

    /**
     * Test the JAXB based APIs on the LogicalMessage interface.
     * @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);
View Full Code Here

        msg.setBodyBlock(block);
       
        MessageContext mc = new MessageContext();
        mc.setMessage(msg);
       
        LogicalMessageContext lmc = MessageContextFactory.createLogicalMessageContext(mc);
       
        return lmc;
    }
View Full Code Here

        msg.setXMLFault(fault);
       
        MessageContext mc = new MessageContext();
        mc.setMessage(msg);
       
        LogicalMessageContext lmc = MessageContextFactory.createLogicalMessageContext(mc);
       
        return lmc;
    }
View Full Code Here

TOP

Related Classes of javax.xml.ws.handler.LogicalMessageContext

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.