List of usage examples for javax.xml.transform.stream StreamSource StreamSource
public StreamSource(File f)
From source file:sample.ws.service.SampleWsApplicationTests.java
@Test public void testHelloRequest() { // final String request = // "<q0:sayHello xmlns:q0=\"http://service.ws.sample\">Elan</q0:sayHello>"; String request = "<q0:sayHello xmlns:q0=\"http://service.ws.sample/\"><myname>Elan</myname></q0:sayHello>"; StreamSource source = new StreamSource(new StringReader(request)); StreamResult result = new StreamResult(System.out); this.webServiceTemplate.sendSourceAndReceiveToResult(source, result); assertThat(this.output.toString(), containsString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<ns2:sayHelloResponse xmlns:ns2=\"http://service.ws.sample/\">" + "<return>Hello, Welcome to CXF Spring boot Elan!!!</return>" + "</ns2:sayHelloResponse>")); }
From source file:no.digipost.api.handlers.KvitteringSender.java
@Override public void doWithMessage(final WebServiceMessage message) throws IOException, TransformerException { SoapMessage soapMessage = (SoapMessage) message; SimpleStandardBusinessDocument simple = new SimpleStandardBusinessDocument(appKvittering.sbd); if (appKvittering.sbdStream != null) { TransformerUtil.transform(new StreamSource(appKvittering.sbdStream), soapMessage.getEnvelope().getBody().getPayloadResult(), true); } else if (simple.getMelding().getSignature() == null) { Document signedDoc = signer.sign(appKvittering.sbd); Marshalling.marshal(signedDoc, soapMessage.getEnvelope().getBody().getPayloadResult()); } else {/* w ww . j a va 2s. c o m*/ Marshalling.marshal(marshaller, soapMessage.getEnvelope().getBody(), appKvittering.sbd); } Mpc mpc = new Mpc(appKvittering.prioritet, appKvittering.mpcId); ebmsContext.addRequestStep(new AddUserMessageStep(mpc, appKvittering.messageId, appKvittering.action, null, appKvittering.sbd, tekniskAvsender, tekniskMottaker, marshaller)); }
From source file:edu.wisc.hrs.dao.bnsumm.SoapBenefitSummaryDaoTest.java
@Test @Override//from ww w . j a v a 2 s . c om public void testGetBenefitSummary() throws Exception { final WebServiceMessage webServiceMessage = setupWebServiceMessageSender(); when(webServiceMessage.getPayloadSource()) .thenReturn(new StreamSource(this.getClass().getResourceAsStream("/hrs/bnsumm.xml"))); super.testGetBenefitSummary(); }
From source file:org.web4thejob.orm.CriterionImpl.java
@SuppressWarnings("rawtypes") private Object deserializeValue(String flatValue) { final Unmarshaller unmarshaller = ContextUtil.getBean(Unmarshaller.class); try {//from www. java 2 s . c o m Object value = unmarshaller .unmarshal(new StreamSource(new ByteArrayInputStream(flatValue.getBytes("UTF-8")))); if (value instanceof Entity) { try { value = ContextUtil.getDRS().refresh((Entity) value); } catch (HibernateObjectRetrievalFailureException e) { //probably the record has been deleted. return null; } } else if (value instanceof List) { List list = (List) value; if (!list.isEmpty() && list.get(0) instanceof Entity) { for (Object item : list) { try { ContextUtil.getDRS().refresh((Entity) item); } catch (HibernateObjectRetrievalFailureException e) { //probably the record has been deleted. return list.remove(item); } } } } return value; } catch (final Exception e) { throw new RuntimeException(e); } }
From source file:com.predic8.membrane.core.interceptor.rest.SOAPRESTHelper.java
protected StreamSource getExchangeXMLSource(Exchange exc) throws Exception { com.predic8.membrane.core.http.xml.Exchange xmlExc = new com.predic8.membrane.core.http.xml.Exchange(exc); String res = xmlExc.toXml();/*ww w . j av a 2 s .c o m*/ log.debug("http-xml: " + res); return new StreamSource(new StringReader(res)); }
From source file:edu.wisc.hrs.dao.msstime.SoapManagerTimeDaoTest.java
@Test @Override//from w ww .ja v a 2s .com public void testGetManagerTime() throws Exception { final WebServiceMessage webServiceMessage = setupWebServiceMessageSender(); when(webServiceMessage.getPayloadSource()) .thenReturn(new StreamSource(this.getClass().getResourceAsStream("/hrs/msstime.xml"))); super.testGetManagerTime(); }
From source file:edu.wisc.hrs.dao.mssabs.SoapManagerAbsenceDaoTest.java
@Test @Override//ww w . j a v a 2 s . c om public void testManagedAbsences() throws Exception { final WebServiceMessage webServiceMessage = setupWebServiceMessageSender(); when(webServiceMessage.getPayloadSource()) .thenReturn(new StreamSource(this.getClass().getResourceAsStream("/hrs/mssabs.xml"))); super.testManagedAbsences(); }
From source file:nl.ase.calculator.CalculatorWsApplicationTests.java
@Test public void testSendingHolidayRequest() { final String request = "<cal:CalculateRequest xmlns:cal=\"http://www.han.nl/calculator\">\n" + " <input>\n" + " <!--You may enter the following 2 items in any order-->\n" + " <paramlist>\n" + " <!--1 or more repetitions:-->\n" + " <param>1</param>\n" + " <param>4</param>\n" + " </paramlist>\n" + " <operation>add</operation>\n" + " </input>\n" + " </cal:CalculateRequest>"; StreamSource source = new StreamSource(new StringReader(request)); StreamResult result = new StreamResult(System.out); this.webServiceTemplate.sendSourceAndReceiveToResult(source, result); assertThat(this.output.toString(), containsString("<value>5</value>")); }
From source file:com.cloudbees.plugins.credentials.cli.BaseCredentialsCLICommand.java
protected static HierarchicalStreamReader safeXmlStreamReader(InputStream stream) throws IOException { return safeXmlStreamReader(new StreamSource(stream)); }
From source file:at.ac.tuwien.auto.sewoa.xslt.XsltTransformer.java
private StringWriter _convert(String payload) throws TransformerException { TransformerFactory transformerFactory = TransformerFactory.newInstance(); javax.xml.transform.Transformer transformer = transformerFactory.newTransformer(this.xsltSource); StringWriter stringWriter = new StringWriter(); Source dataSource = new StreamSource(new StringReader(payload)); transformer.transform(dataSource, new StreamResult(stringWriter)); return stringWriter; }