Package javax.xml.ws.handler

Examples of javax.xml.ws.handler.MessageContext


  private static final String ORDER_ID_ATTR = "invoice.orderId";
  private static final String LINE_PRICE_ATTR = "invoice.linePrice";

  public void initiatePriceCalculation(CustomerInfo customerInfo,
      PurchaseOrder purchaseOrder) {
    MessageContext messageContext = serviceContext.getMessageContext();
    ServletContext servletContext =
        (ServletContext) messageContext.get(MessageContext.SERVLET_CONTEXT);
    servletContext.setAttribute(ORDER_ID_ATTR, purchaseOrder.getOrderId());
    // In our system the part number is also the unit price!
    servletContext.setAttribute(LINE_PRICE_ATTR,
        (float) purchaseOrder.getQuantity() * purchaseOrder.getPartNumber());
  }
 
View Full Code Here


      logger.log(Level.SEVERE, "failed to send invoice message", e);
    }
  }

  protected void sendInvoiceMessage(float shippingPrice) throws JMSException {
    MessageContext messageContext = serviceContext.getMessageContext();
    ServletContext servletContext =
        (ServletContext) messageContext.get(MessageContext.SERVLET_CONTEXT);
    Integer orderId = (Integer) servletContext.getAttribute(ORDER_ID_ATTR);
    Float linePrice = (Float) servletContext.getAttribute(LINE_PRICE_ATTR);
    float amount = linePrice + shippingPrice;

    // create a connection
View Full Code Here

        binding.getBindingImpl();
        EasyMock.expectLastCall().andReturn(bindingImpl).times(isRequestor
                                                               ? 6
                                                               : 5);
        bindingImpl.createBindingMessageContext(contexts.get(i));
        MessageContext bindingContext =
            control.createMock(MessageContext.class);
        EasyMock.expectLastCall().andReturn(bindingContext);
        OutputStreamMessageContext outputStreamContext =
            control.createMock(OutputStreamMessageContext.class);
        transport.createOutputStreamContext(bindingContext);
View Full Code Here

        SOAPMessage msg = soapContext.getMessage();
       
        PersistenceUtils pu = new PersistenceUtils();
        InputStream is = pu.getContextAsInputStream(soapContext);
        assert null != is;       
        MessageContext restored = pu.getContext(is);
        assertEquals(3, restored.keySet().size());
        assertEquals(soapContext.get(ObjectMessageContext.MESSAGE_INPUT),
                     restored.get(ObjectMessageContext.MESSAGE_INPUT));
        Object[] params = (Object[])soapContext.get(ObjectMessageContext.METHOD_PARAMETERS);
        Object[] restoredParams = (Object[])restored.get(ObjectMessageContext.METHOD_PARAMETERS);
        assertEquals(params.length, restoredParams.length);
        assertEquals(params[0], restoredParams[0]);
        SOAPMessage restoredMsg = ((SOAPMessageContext)binding.
            createBindingMessageContext(objContext)).getMessage();
        assertEquals(msg.getSOAPBody().getChildNodes().getLength(),
View Full Code Here

        throws IOException, SQLException, SOAPException  {
        IMocksControl control = EasyMock.createNiceControl();
        RMMessage msg = control.createMock(RMMessage.class);
        EasyMock.expect(msg.getMessageNr()).andReturn(mn);
             
        MessageContext ctx = new GenericMessageContext();
        ctx.put("a", "astring");
        ctx.put("b", Boolean.TRUE);
        ctx.put("c", new Integer(Integer.MIN_VALUE));
        ctx.put("d", mn);
        ctx.put("e", this);
        InputStream mis = RMHandlerTest.class.getResourceAsStream("resources/GreetMeDocLiteralRequest.xml");
        SOAPBindingImpl binding = new SOAPBindingImpl(false);
        SOAPMessage smsg = binding.getMessageFactory().createMessage(null, mis);
        ctx.put(SOAP_MSG_KEY, smsg);
        InputStream cis = RMUtils.getPersistenceUtils().getContextAsInputStream(ctx);
        EasyMock.expect(msg.getContextAsStream()).andReturn(cis);
       
        control.replay();
        store.beginTransaction();
View Full Code Here

    public void checkRecoveredMessages(Collection<RMMessage> msgs) throws SOAPException {
        for (RMMessage msg : msgs) {
            BigInteger mn = msg.getMessageNr();           
            assertTrue(BigInteger.ONE.equals(mn)
                       || BigInteger.TEN.equals(mn));
            MessageContext mc = msg.getContext();
            assertEquals("astring", mc.get("a"));
            assertTrue((Boolean)mc.get("b"));
            assertEquals(Integer.MIN_VALUE, ((Integer)mc.get("c")).intValue());
            assertEquals(mn, (BigInteger)mc.get("d"));
            assertNull(mc.get("e"));
            SOAPMessage smsg = (SOAPMessage)mc.get(SOAP_MSG_KEY);
            for (int i = 0; i < smsg.getSOAPBody().getChildNodes().getLength(); i++) {
                Node node = smsg.getSOAPBody().getChildNodes().item(i);
                if (Node.ELEMENT_NODE == node.getNodeType()) {
                    assertEquals("greetMeRequest", node.getLocalName());
                }
View Full Code Here

            if (!(handler.getClientBinding() == null || isOneway)) {
                Response response =
                    ((AbstractClientBinding)handler.getClientBinding())
                        .getResponseCorrelator().getResponse(request);
                response.setHandlerInvoker(request.getHandlerInvoker());
                MessageContext responseContext = response.getBindingMessageContext();
                DataBindingCallback responseCallback =
                    BindingContextUtils.retrieveDataBindingCallback(responseContext);
                response.processLogical(responseCallback);
            }
        } else {
View Full Code Here

        }
        return new ByteArrayInputStream(bos.toByteArray());
    }
   
    public MessageContext getContext(InputStream is) {
        MessageContext ctx = new GenericMessageContext();
        try {
            ObjectInput oi = new ObjectInputStream(is);
            int nKeys = oi.readInt();
           
            for (int i = 0; i < nKeys; i++) {
                String key = (String)oi.readObject();
                Object value = oi.readObject();
                ctx.put(key, value);
            }
           
            // construct SOAPMessage from input stream
           
            SOAPMessage msg = getMessageFactory().createMessage(null, is);
            ctx.put(SOAP_MSG_KEY, msg);
           
        } catch (Exception ex) {
            throw new RMStoreException(ex)
        }
        return ctx;
View Full Code Here

                                      StreamSource.class,
                                      Service.Mode.MESSAGE);
    }
   
    private void updateRequestContext(Map<String, Object> reqCtx) {
        MessageContext sourceMsgCtx = getContext().getMessageContext();
        reqCtx.put(BindingProvider.USERNAME_PROPERTY,
                   sourceMsgCtx.get(BindingProvider.USERNAME_PROPERTY));
        reqCtx.put(BindingProvider.PASSWORD_PROPERTY,
                   sourceMsgCtx.get(BindingProvider.PASSWORD_PROPERTY));       
    }
View Full Code Here

        return Service.create(wsdlUrl, serviceName);
    }
   
    private void updateRequestContext(Map<String, Object> reqCtx) {
        if (null != getContext()) {
            MessageContext sourceMsgCtx = getContext().getMessageContext();
            reqCtx.put(BindingProvider.USERNAME_PROPERTY,
                       sourceMsgCtx.get(BindingProvider.USERNAME_PROPERTY));
            reqCtx.put(BindingProvider.PASSWORD_PROPERTY,
                       sourceMsgCtx.get(BindingProvider.PASSWORD_PROPERTY));
        }
    }
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.