SOAPMessage sm = response; SOAPBody sb = response.getSOAPBody(); Document d = sb.extractContentAsDocument(); DOMSource source = new DOMSource(d); results = (FindEventsResponse) JAXB.unmarshal(source, FindEventsResponse.class);
SOAPBody sb = soapResponse.getSOAPBody(); Document XMLDoc = sb.extractContentAsDocument(); NodeList nl = XMLDoc.getElementsByTagName("ObtenerImagenResult"); String response = nl.item(0).getFirstChild().getNodeValue(); return response;
/** * Given a {@link SOAPMessage}, get the content as a {@link Document} * @param soapMessage * @return * @throws SOAPException */ public static Document getSOAPData(SOAPMessage soapMessage) throws SOAPException { return soapMessage.getSOAPBody().extractContentAsDocument(); }
/** * Given a {@link SOAPMessage}, get the content as a {@link Document} * * @param soapMessage * @return * @throws SOAPException */ public static Document getSOAPData(SOAPMessage soapMessage) throws SOAPException { return soapMessage.getSOAPBody().extractContentAsDocument(); }
@WebServiceProvider @ServiceMode(value=Service.Mode.MESSAGE) public class TestProvider implements Provider<SOAPMessage> { public SOAPMessage invoke(SOAPMessage request) { SOAPBody requestBody = request.getSOAPBody(); Document document = requestBody.extractContentAsDocument(); ...//Unmarshling and validating SOAP payload. Same as described in option A } }
/** * Given a {@link SOAPMessage}, get the content as a {@link Document} * * @param soapMessage * * @return * * @throws SOAPException */ public static Document getSOAPData(SOAPMessage soapMessage) throws SOAPException { return soapMessage.getSOAPBody().extractContentAsDocument(); }
/** * Given a {@link SOAPMessage}, get the content as a {@link Document} * @param soapMessage * @return * @throws SOAPException */ public static Document getSOAPData(SOAPMessage soapMessage) throws SOAPException { return soapMessage.getSOAPBody().extractContentAsDocument(); }
/** * Given a {@link SOAPMessage}, get the content as a {@link Document} * * @param soapMessage * * @return * * @throws SOAPException */ public static Document getSOAPData(SOAPMessage soapMessage) throws SOAPException { return soapMessage.getSOAPBody().extractContentAsDocument(); }
/** * Method reads SOAP body element from SOAP Envelope and transforms body payload to String. * * @param request * @return * @throws javax.xml.soap.SOAPException * @throws java.io.IOException * @throws javax.xml.transform.TransformerException */ public String getSoapBody(Message request) throws SOAPException, IOException, TransformerException { MessageFactory msgFactory = MessageFactory.newInstance(); MimeHeaders mimeHeaders = new MimeHeaders(); mimeHeaders.addHeader("Content-Type", "text/xml; charset=" + Charset.forName(System.getProperty("citrus.file.encoding", "UTF-8"))); SOAPMessage message = msgFactory.createMessage(mimeHeaders, new ByteArrayInputStream(request.getPayload().toString().getBytes(System.getProperty("citrus.file.encoding", "UTF-8")))); SOAPBody soapBody = message.getSOAPBody(); Document body = soapBody.extractContentAsDocument(); StringResult result = new StringResult(); transformerFactory.newTransformer().transform(new DOMSource(body), result); return result.toString(); }
public Object read(int idx, T input) { Source obj = null; SOAPBody src = (SOAPBody)input; try { Document doc = src.extractContentAsDocument(); assert doc != null; if (DOMSource.class.isAssignableFrom(callback.getSupportedFormats()[0])) { obj = new DOMSource(); ((DOMSource)obj).setNode(doc); } else if (SAXSource.class.isAssignableFrom(callback.getSupportedFormats()[0])) { InputSource inputSource = new InputSource(getSOAPBodyStream(doc)); obj = new SAXSource(inputSource); } else if (StreamSource.class.isAssignableFrom(callback.getSupportedFormats()[0])) { obj = new StreamSource(getSOAPBodyStream(doc)); } else if (Object.class.isAssignableFrom(callback.getSupportedFormats()[0])) { JAXBContext context = callback.getJAXBContext(); Unmarshaller u = context.createUnmarshaller(); return u.unmarshal(doc); } } catch (Exception se) { se.printStackTrace(); } return obj; }
public static void validate(Path path, XSDDefinition xsdDefinition) { try { Schema schema = xsdDefinition.getSchema(); Validator validator = schema.newValidator(); Source source; if (xsdDefinition.isWsdl()) { MessageFactory mf = MessageFactory.newInstance(); SOAPMessage soapMessage = mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(Files.readAllBytes(path))); Document doc = soapMessage.getSOAPBody().extractContentAsDocument(); source = new DOMSource(doc); } else { source = new StreamSource(path.toFile()); } validator.setErrorHandler(new XmlErrorHandler(path)); validator.validate(source); } catch (Exception ex) { throw new RuntimeException("Error validate XML " + path, ex); } }
public HWDOMSourcePayloadProvider() { try { factory = MessageFactory.newInstance(); InputStream is = getClass().getResourceAsStream("resources/sayHiRpcLiteralResp.xml"); sayHiResponse = factory.createMessage(null, is).getSOAPBody().extractContentAsDocument(); is.close(); is = getClass().getResourceAsStream("resources/GreetMeRpcLiteralResp.xml"); greetMeResponse = factory.createMessage(null, is).getSOAPBody().extractContentAsDocument(); is.close(); } catch (Exception ex) { ex.printStackTrace(); } }
public HWSAXSourcePayloadProvider() { try { factory = MessageFactory.newInstance(); InputStream is = getClass().getResourceAsStream("resources/sayHiRpcLiteralResp.xml"); Document sayHiDocument = factory.createMessage(null, is).getSOAPBody().extractContentAsDocument(); sayHiInputSource = new InputSource(getSOAPBodyFile(sayHiDocument).toURI().toString()); InputStream is2 = getClass().getResourceAsStream("resources/GreetMeRpcLiteralResp.xml"); Document greetMeDocument = factory.createMessage(null, is2).getSOAPBody().extractContentAsDocument(); greetMeInputSource = new InputSource(getSOAPBodyFile(greetMeDocument).toURI().toString()); } catch (Exception ex) { ex.printStackTrace(); } }
try { SOAPMessage soapMessage = (SOAPMessage) args[0]; Node node = soapMessage.getSOAPBody().extractContentAsDocument();
public HWStreamSourcePayloadProvider() { try { factory = MessageFactory.newInstance(); InputStream is = getClass().getResourceAsStream("resources/sayHiRpcLiteralResp.xml"); Document sayHiDocument = factory.createMessage(null, is).getSOAPBody().extractContentAsDocument(); sayHiInputStream = getSOAPBodyStream(sayHiDocument); InputStream is2 = getClass().getResourceAsStream("resources/GreetMeRpcLiteralResp.xml"); Document greetMeDocument = factory.createMessage(null, is2).getSOAPBody().extractContentAsDocument(); greetMeInputStream = getSOAPBodyStream(greetMeDocument); } catch (Exception ex) { ex.printStackTrace(); } }
public Message parseMessage() { Message output = null; try { String relatesTo = getElementValue(HEADER_RELATESTO); String action = getElementValue(HEADER_ACTION); if (relatesTo != null && !relatesTo.isEmpty() && action != null && action.endsWith("Response")) { if (soapMessage.getSOAPBody().hasFault()) output = parseError(); else output = parseResult(); } else { output = parseCall(); } if (action != null && !action.isEmpty()) output.setAction(action.substring(1)); if (!soapMessage.getSOAPBody().hasFault()) output.setPayload(soapMessage.getSOAPBody().extractContentAsDocument()); } catch (SOAPException e) { logger.warn("parseMessage() failed", e); } return output; }
/** * Parses the SOAPBody content to a text representation * * @param message * SOAP message * * @return SOAPBody content as text * * * @throws DecodingException * * if an error occurs. */ protected OwsServiceRequest getSOAPBodyContent(SOAPMessage message) throws DecodingException { try { Document bodyRequestDoc = message.getSOAPBody().extractContentAsDocument(); String xmlString = W3cHelper.nodeToXmlString(bodyRequestDoc.getDocumentElement()); return decodeXmlElement(XmlObject.Factory.parse(xmlString, getXmlOptions())); } catch (SOAPException | XmlException | IOException e) { throw new DecodingException("Error while parsing SOAPMessage body content!", e); } }
@Override protected void done() { if (!isCancelled()) { try { SOAPMessage msg = get(); if (msg.getSOAPBody().hasFault()) { op.setResponseDocument(msg.getSOAPBody().getFault().getOwnerDocument()); } else { op.setResponseDocument(msg.getSOAPBody().extractContentAsDocument()); } } catch (CancellationException cancelled) { // it was aborted, nothing to do since the // abort method sets the state } catch (ExecutionException e) { //something went awry op.fail(e.getCause()); } catch (Exception e) { //something went awry op.fail(e); } } } }
/** * Parses the SOAPBody content to a text representation * * @param message * SOAP message * * @return SOAPBody content as text * * * @throws OwsExceptionReport * * if an error occurs. */ protected XmlObject getSOAPBodyContent(SOAPMessage message) throws OwsExceptionReport { try { Document bodyRequestDoc = message.getSOAPBody().extractContentAsDocument(); XmlOptions options = XmlOptionsHelper.getInstance().getXmlOptions(); String xmlString = W3cHelper.nodeToXmlString(bodyRequestDoc.getDocumentElement()); return XmlObject.Factory.parse(xmlString, options); } catch (SOAPException soape) { throw new InvalidRequestException().causedBy(soape).withMessage( "Error while parsing SOAPMessage body content!"); } catch (XmlException xmle) { throw new InvalidRequestException().causedBy(xmle).withMessage( "Error while parsing SOAPMessage body content!"); } }
DOMSource domReqMsg = new DOMSource(soapReqMsg.getSOAPBody().extractContentAsDocument()); assertNotNull(domReqMsg); DOMSource domReqMsg1 = new DOMSource(soapReqMsg1.getSOAPBody().extractContentAsDocument()); assertNotNull(domReqMsg1); DOMSource domReqMsg2 = new DOMSource(soapReqMsg2.getSOAPBody().extractContentAsDocument()); assertNotNull(domReqMsg2); DOMSource domReqMsg3 = new DOMSource(soapReqMsg3.getSOAPBody().extractContentAsDocument()); assertNotNull(domReqMsg3);