Package org.apache.servicemix.jbi.messaging

Examples of org.apache.servicemix.jbi.messaging.NormalizedMessageImpl


                    Message outMessage = ex.getOutMessage();
                    if (outMessage == null) {
                        outMessage = endpoint.getBinding().createMessage();
                        ex.setOutMessage(outMessage);
                    }
                    NormalizedMessageImpl norMessage =
                        (NormalizedMessageImpl) exchange.getMessage("out");
                    List<Attachment> attachmentList = new ArrayList<Attachment>();
                    outMessage.setContent(Source.class, exchange.getMessage(
                            "out").getContent());
                    Iterator<String> iter = norMessage.listAttachments();
                    while (iter.hasNext()) {
                        String id = iter.next();
                        DataHandler dh = norMessage.getAttachment(id);
                        attachmentList.add(new AttachmentImpl(id, dh));
                    }
                   
                    message.setAttachments(attachmentList);
                }
View Full Code Here


    }
   
    public void handleMessage(Message message) {
        List<Attachment> attachmentList = new ArrayList<Attachment>();
        MessageExchange exchange = message.get(MessageExchange.class);
        NormalizedMessageImpl norMessage =
            (NormalizedMessageImpl) exchange.getMessage("in");
        Iterator<String> iter = norMessage.listAttachments();
        while (iter.hasNext()) {
            String id = iter.next();
            DataHandler dh = norMessage.getAttachment(id);
            attachmentList.add(new AttachmentImpl(id, dh));
        }
       
        LOG.info("the attachment size is " + attachmentList.size());
        message.setAttachments(attachmentList);
View Full Code Here

        //assertExpression(new XMLBeansStringXPathExpression("foo/bar/text()"), "cheese", "<foo><bar>cheese</bar></foo>");
    }

    protected void assertExpression(Expression expression, String expected, String xml) throws MessagingException {
        MessageExchangeImpl exchange = new InOnlyImpl("dummy");
        NormalizedMessage message = new NormalizedMessageImpl(exchange);
        message.setProperty("name", "James");
        message.setContent(new StringSource(xml));
        Object value = expression.evaluate(exchange, message);
        assertEquals("Expression: " + expression, expected, value);
    }
View Full Code Here

   * helper method to return a new JBI NormalizedMessage when we need one
   *
   * @return
   */
  private NormalizedMessage makeTestMessage(String xml) {
    NormalizedMessage message = new NormalizedMessageImpl();
    message.setProperty(PROPNAME, TEST_STRING);
    if (xml == null) {
      xml = "<this><is><some attr='1234'>xml123</some></is></this>";
    }
    try {
      DocumentBuilder db;
      db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      Document dom = db.parse(new InputSource(new StringReader(xml)));
      message.setContent(new DOMSource(dom));
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }
    return message;
  }
View Full Code Here

   * helper method to return a new JBI NormalizedMessage
   * when we need one
   * @return
   */
  private NormalizedMessage getTestMessage() {
    NormalizedMessage message = new NormalizedMessageImpl();
    message.setProperty(PROPNAME,TEST_STRING);
    String xml = "<this><is><some attr='1234'>xml123</some></is></this>";
    try {
      DocumentBuilder db;
      db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      Document dom = db.parse(new InputSource(new StringReader(xml)));
      message.setContent(new DOMSource(dom));
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }
    return message;
  }
View Full Code Here

  protected void testToNMS(MessageFactory messageFactory) throws Exception {
    MimeHeaders headers = new MimeHeaders();
    headers.addHeader("Content-Type", "text/xml;");
    InputStream is = getClass().getClassLoader().getResourceAsStream("org/apache/servicemix/components/http/soap-response.xml");
    SOAPMessage sm = messageFactory.createMessage(headers, is);
    NormalizedMessage nm = new NormalizedMessageImpl();
    new SaajMarshaler().toNMS(nm, sm);

        Node node = new SourceTransformer().toDOMNode(new SourceTransformer().toStreamSource(nm.getContent()));
        logger.info(new SourceTransformer().toString(node));
   
        CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
        NodeIterator iterator = cachedXPathAPI.selectNodeIterator(node, "//*[local-name() = 'userId']");
        Element root = (Element) iterator.nextNode();
View Full Code Here

        
        InputStream is = getClass().getClassLoader().getResourceAsStream("org/apache/servicemix/components/saaj/xml-request.xml");        
        logger.info("Raw XML: {}", new SourceTransformer().toString(new StreamSource(is)));
        
        is = getClass().getClassLoader().getResourceAsStream("org/apache/servicemix/components/saaj/xml-request.xml");        
        NormalizedMessage nm = new NormalizedMessageImpl();
        nm.setContent(new StreamSource(is));
          
        SaajMarshaler marshaler = new SaajMarshaler();
        marshaler.setMessageFactory(messageFactory);
        SOAPMessage msg = marshaler.createSOAPMessage(nm);
       
View Full Code Here

   * helper method to return a new JBI NormalizedMessage
   * when we need one
   * @return
   */
  private NormalizedMessage makeTestMessage(String xml) {
    NormalizedMessage message = new NormalizedMessageImpl();
    message.setProperty(PROPNAME,TEST_STRING);
    if (xml == null) {
        xml = SAMPLE_MSG_XML2;
    }
    try {
      DocumentBuilder db;
      db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      Document dom = db.parse(new InputSource(new StringReader(xml)));
      message.setContent(new DOMSource(dom));
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }
    return message;
  }
View Full Code Here

        r.close();
        new SourceTransformer().contentToString(msg);
    }
   
    protected NormalizedMessage copyMessage(Source src) throws Exception {
        NormalizedMessage from = new NormalizedMessageImpl();
        NormalizedMessage to = new NormalizedMessageImpl();
        from.setContent(src);
        transformer.transform(null, from, to);
        return to;
    }
View Full Code Here

   * helper method to return a new JBI NormalizedMessage
   * when we need one
   * @return
   */
  private NormalizedMessage makeTestMessage(String xml) {
    NormalizedMessage message = new NormalizedMessageImpl();
    message.setProperty(PROPNAME,TEST_STRING);
    if (xml == null) {
        xml = SAMPLE_MSG_XML2;
    }
    try {
      DocumentBuilder db;
      db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      Document dom = db.parse(new InputSource(new StringReader(xml)));
      message.setContent(new DOMSource(dom));
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }
    return message;
  }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.jbi.messaging.NormalizedMessageImpl

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.