Package org.springframework.xml.transform

Examples of org.springframework.xml.transform.StringSource


    @Test
    public void testHandler() throws Exception {
        String content = "<Root xmlns='http://springframework.org/spring-ws/1' " +
                "xmlns:child='http://springframework.org/spring-ws/2'>" +
                "<child:Child attribute='value'>Content</child:Child></Root>";
        Source source = new StringSource(content);
        Result result = new SAXResult(handler);
        transformer.transform(source, result);
        Name rootName = envelope.createName("Root", "", "http://springframework.org/spring-ws/1");
        Iterator<?> iterator = envelope.getBody().getChildElements(rootName);
        Assert.assertTrue("No child found", iterator.hasNext());
View Full Code Here


  private final WebServiceTemplate template = new WebServiceTemplate();

  @Test
  public void testWebServiceRequestAndResponse() {
    StringResult result = new StringResult();
    Source payload = new StringSource(
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
        "<echoRequest xmlns=\"http://www.springframework.org/spring-ws/samples/echo\">hello</echoRequest>");

    template.sendSourceAndReceiveToResult(WS_URI, payload, result);
    logger.info("RESULT: " + result.toString());
View Full Code Here

    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
    transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", String.valueOf(2));
    StreamResult streamResult = new StreamResult(new StringWriter());
    Source source = new StringSource(result);
    transformer.transform(source, streamResult);
    String xmlString = streamResult.getWriter().toString();
    return xmlString;
  }
View Full Code Here

    String xmlString = "<weat:GetCityWeatherByZIP xmlns:weat=\"http://ws.cdyne.com/WeatherWS/\">" +
              "  <weat:ZIP>" + zip + "</weat:ZIP>" +
              "</weat:GetCityWeatherByZIP>";
    try {
      Transformer transformer = transformerFactory.newTransformer();
      transformer.transform(new StringSource(xmlString), result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    }

    public void testTemplate() throws Exception {
        WebServiceTemplate template = new WebServiceTemplate(messageFactory);
        template.setMessageSender(messageSender);
        template.sendSourceAndReceiveToResult("tcp://localhost", new StringSource(REQUEST),
                new StreamResult(System.out));
    }
View Full Code Here

    }

    public void testJmsTransport() throws Exception {
        String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
        StringResult result = new StringResult();
        webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result);
        XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
        applicationContext.close();
    }
View Full Code Here

    @Test
    public void testMailTransport() throws Exception {
        String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
        StringResult result = new StringResult();
        webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result);
        applicationContext.close();
        assertEquals("Server mail message not deleted", 0, Mailbox.get("server@example.com").size());
        assertEquals("No client mail message received", 1, Mailbox.get("client@example.com").size());
        XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
View Full Code Here

    @Test
    public void testTemporaryQueue() throws Exception {
        String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
        StringResult result = new StringResult();
        webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result);
        XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
    }
View Full Code Here

    @Test
    public void testPermanentQueue() throws Exception {
        String url = "jms:RequestQueue?deliveryMode=NON_PERSISTENT;replyToName=ResponseQueue";
        String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
        StringResult result = new StringResult();
        webServiceTemplate.sendSourceAndReceiveToResult(url, new StringSource(content), result);
        XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
    }
View Full Code Here

    protected void assertXpathEvaluatesTo(String message,
                                          String expectedValue,
                                          String xpathExpression,
                                          String document) {
        String actualValue = xpathTemplate.evaluateAsString(xpathExpression, new StringSource(document));
        Assert.assertEquals(message, expectedValue, actualValue);
    }
View Full Code Here

TOP

Related Classes of org.springframework.xml.transform.StringSource

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.