Refine search
MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("example", serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("VerifyEmail", "example"); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("email", "example"); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); Source sourceContent = soapResponse.getSOAPPart().getContent(); System.out.print("\nResponse SOAP Message = "); StreamResult result = new StreamResult(System.out);
/** * Gets the SOAP Body contained in this <code>SOAPMessage</code> object. * * @return the <code>SOAPBody</code> object contained by this <code>SOAPMessage</code> object * @throws javax.xml.soap.SOAPException if the SOAP Body does not exist or cannot be retrieved */ public SOAPBody getSOAPBody() throws SOAPException { return this.soapPart.getEnvelope().getBody(); }
public class MyCustomHandler implements SOAPHandler<SOAPMessageContext> { @Override public boolean handleMessage(SOAPMessageContext context) { SOAPMessage msg = context.getMessage(); SOAPEnvelope env = msg.getSOAPPart().getEnvelope(); SOAPBody body = env.getBody(); // now when you have SOAP body you can do whatever you want... return true; } }
MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("example", serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("VerifyEmail", "example"); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("email", "example"); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); Source sourceContent = soapResponse.getSOAPPart().getContent(); System.out.print("\nResponse SOAP Message = "); StreamResult result = new StreamResult(System.out);
final SOAPMessage msg = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL) .createMessage(new MimeHeaders(), new ByteArrayInputStream(yourSoapMessageWithFault.getBytes())); if (msg != null) { SOAPEnvelope env = msg.getSOAPPart().getEnvelope(); SOAPBody body = env.getBody(); if (body != null && body.hasFault()) { final SOAPFault fault = body.getFault(); final DetailEntry entry = (DetailEntry)fault.getDetail().getDetailEntries().next(); //now UNMarshall this entry to your custom exception class.
/** * Gets the SOAP Body contained in this <code>SOAPMessage</code> object. * * @return the <code>SOAPBody</code> object contained by this <code>SOAPMessage</code> object * @throws javax.xml.soap.SOAPException if the SOAP Body does not exist or cannot be retrieved */ public SOAPBody getSOAPBody() throws SOAPException { return this.soapPart.getEnvelope().getBody(); }
MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("example", serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("VerifyEmail", "example"); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("email", "example");
MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); // Retrieve different parts SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope(); soapEnvelope.addNamespaceDeclaration("xsd", "http://www.w3.org/2001/XMLSchema"); soapEnvelope.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance"); // Two ways to extract headers // SOAPHeader soapHeader = soapEnvelope.getHeader(); // soapHeader = soapMessage.getSOAPHeader(); // Two ways to extract body SOAPBody soapBody = soapEnvelope.getBody(); soapBody = soapMessage.getSOAPBody(); // To add some element SOAPElement GetParamter=soapBody.addBodyElement(new javax.xml.namespace.QName("http://examples/2001", "GetParamter")); GetParamter = GetParamter.addChildElement(new javax.xml.namespace.QName("request")); SOAPElement MonCode=GetParamter.addChildElement(new javax.xml.namespace.QName("http://newsite/mon", "MonCode")); MonCode.addTextNode("Latency"); SOAPElement TimeFrom=GetParamter.addChildElement(new javax.xml.namespace.QName("http://newsite/mon", "TimeFrom")); TimeFrom.addTextNode("2016-10-26T11:00"); SOAPElement TimeTo=GetParamter.addChildElement(new javax.xml.namespace.QName("http://newsite/mon", "TimeTo")); TimeTo.addTextNode("2016-10-26T12:00");
public SOAPBody getSOAPBody() throws SOAPException { SOAPPart soapPart = getSOAPPart(); if (soapPart != null) { SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); if (soapEnvelope != null) { SOAPBody soapBody = soapEnvelope.getBody(); return soapBody; } } throw new SOAPException(BundleUtils.getMessage(bundle, "CANNOT_OBTAIN_SOAPBODY")); }
private XMLStreamReader createXMLStreamReaderFromSOAPMessage(SOAPMessage soapMessage) { // responseMsg.setContent(SOAPMessage.class, soapMessage); XMLStreamReader xmlReader = null; try { DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody()); xmlReader = StaxUtils.createXMLStreamReader(bodySource); xmlReader.nextTag(); xmlReader.nextTag(); // move past body tag } catch (SOAPException | XMLStreamException e) { e.printStackTrace(); } return xmlReader; }
MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); // Retrieve different parts SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope(); // Two ways to extract headers SOAPHeader soapHeader = soapEnvelope.getHeader(); soapHeader = soapMessage.getSOAPHeader(); // Two ways to extract body SOAPBody soapBody = soapEnvelope.getBody(); soapBody = soapMessage.getSOAPBody(); // To add some element SOAPFactory soapFactory = SOAPFactory.newInstance(); Name bodyName = soapFactory.createName("getEmployeeDetails","ns1","urn:MySoapServices"); SOAPBodyElement purchaseLineItems = soapBody.addBodyElement(bodyName); Name childName = soapFactory.createName("param1"); SOAPElement order = purchaseLineItems.addChildElement(childName); childName.addTextNode("1016577");
private XMLStreamReader createXMLStreamReaderFromSOAPMessage(SOAPMessage soapMessage) { // responseMsg.setContent(SOAPMessage.class, soapMessage); XMLStreamReader xmlReader = null; try { DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody()); xmlReader = StaxUtils.createXMLStreamReader(bodySource); xmlReader.nextTag(); xmlReader.nextTag(); // move past body tag } catch (SOAPException | XMLStreamException e) { e.printStackTrace(); } return xmlReader; }
if (isRequestor(message) && msg.getSOAPPart().getEnvelope().getBody() != null && msg.getSOAPPart().getEnvelope().getBody().hasFault()) { return null;
.getSOAPPart().getEnvelope().getBody().addFault(); } catch (Throwable t2) {
SOAPBody body = originalMsg.getSOAPPart().getEnvelope().getBody(); body.removeContents(); soapFault.setFaultActor(sf.getFault().getFaultActor()); if (sf.getFault().hasDetail()) { Node nd = originalMsg.getSOAPPart().importNode( sf.getFault().getDetail() .getFirstChild(), true); if (sf.hasDetails()) { soapFault.addDetail(); Node nd = originalMsg.getSOAPPart().importNode(sf.getDetail(), true); nd = nd.getFirstChild(); while (nd != null) {
public static SOAPBody getBody(SOAPMessage m) throws SOAPException { try { return m.getSOAPBody(); } catch (UnsupportedOperationException ex) { return m.getSOAPPart().getEnvelope().getBody(); } catch (IllegalArgumentException ex) { //java9 return null; } } public static void setFaultCode(SOAPFault f, QName code) throws SOAPException {
public static SOAPBody getBody(SOAPMessage m) throws SOAPException { try { return m.getSOAPBody(); } catch (UnsupportedOperationException ex) { return m.getSOAPPart().getEnvelope().getBody(); } catch (IllegalArgumentException ex) { //java9 return null; } } public static void setFaultCode(SOAPFault f, QName code) throws SOAPException {
private XMLStreamReader createXMLStreamReaderFromSOAPMessage(SOAPMessage soapMessage) { // responseMsg.setContent(SOAPMessage.class, soapMessage); XMLStreamReader xmlReader = null; try { DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody()); xmlReader = StaxUtils.createXMLStreamReader(bodySource); xmlReader.nextTag(); xmlReader.nextTag(); // move past body tag } catch (SOAPException | XMLStreamException e) { e.printStackTrace(); } return xmlReader; }
private XMLStreamReader createXMLStreamReaderFromSOAPMessage(SOAPMessage soapMessage) { // responseMsg.setContent(SOAPMessage.class, soapMessage); XMLStreamReader xmlReader = null; try { DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody()); xmlReader = StaxUtils.createXMLStreamReader(bodySource); xmlReader.nextTag(); xmlReader.nextTag(); // move past body tag } catch (SOAPException | XMLStreamException e) { e.printStackTrace(); } return xmlReader; }
private SOAPBody getBody(final SOAPMessage message) { try { return message.getSOAPPart().getEnvelope().getBody(); } catch (final SOAPException e) { throw new ServerRuntimeException(e); } }