/** * Add content to {@link SOAPMessage} * * @param data * @param soapMessage * @throws SOAPException */ public static void addData(Source data, SOAPMessage soapMessage) throws SOAPException { try { soapMessage.getSOAPBody().addDocument(DocumentUtil.getDocumentFromSource(data)); } catch (GeneralSecurityException e) { throw new RuntimeException(e); } }
message.getSOAPBody().addDocument(document);
/** * Add content to {@link SOAPMessage} * * @param data * @param soapMessage * * @throws SOAPException */ public static void addData(Source data, SOAPMessage soapMessage) throws SOAPException { try { soapMessage.getSOAPBody().addDocument(DocumentUtil.getDocumentFromSource(data)); } catch (GeneralSecurityException e) { throw new RuntimeException(e); } }
/** * Add content to {@link SOAPMessage} * @param data * @param soapMessage * @throws SOAPException */ public static void addData(Source data, SOAPMessage soapMessage) throws SOAPException { try { soapMessage.getSOAPBody().addDocument(DocumentUtil.getDocumentFromSource(data)); } catch (GeneralSecurityException e) { throw new RuntimeException(e); } } }
/** * Add content to {@link SOAPMessage} * * @param data * @param soapMessage * * @throws SOAPException */ public static void addData(Source data, SOAPMessage soapMessage) throws SOAPException { try { soapMessage.getSOAPBody().addDocument(DocumentUtil.getDocumentFromSource(data)); } catch (GeneralSecurityException e) { throw new RuntimeException(e); } }
/** * Add content to {@link SOAPMessage} * @param data * @param soapMessage * @throws SOAPException */ public static void addData(Source data, SOAPMessage soapMessage) throws SOAPException { try { soapMessage.getSOAPBody().addDocument(DocumentUtil.getDocumentFromSource(data)); } catch (GeneralSecurityException e) { throw new RuntimeException(e); } } }
private SOAPMessage createResponse(Object body) throws InvocationTargetException { try { SOAPMessage soapMessage = factory.createMessage(); soapMessage.getSOAPBody().addDocument((Document) body); soapMessage.saveChanges(); return soapMessage; } catch (SOAPException e) { throw new InvocationTargetException(e); } }
body.addDocument(document);
private SOAPMessage convert(Source theResponse) { try { SOAPMessage response = SOAPUtil.create(); Document theResponseDoc = (Document) DocumentUtil.getNodeFromSource(theResponse); response.getSOAPBody().addDocument(theResponseDoc); return response; } catch (Exception e) { throw new WebServiceException(e); } }
private SOAPMessage convert(Source theResponse) { try { SOAPMessage response = SOAPUtil.create(); Document theResponseDoc = (Document) DocumentUtil.getNodeFromSource(theResponse); response.getSOAPBody().addDocument(theResponseDoc); return response; } catch (Exception e) { throw new WebServiceException(e); } }
public SOAPMessage wrapInSoapEnvelope(Document document, Set<SoapHeader> headers) { try { final SOAPMessage message = messageFactory.createMessage(); addHeaders(document, message.getSOAPHeader(), headers); message.getSOAPBody().addDocument(document); return message; } catch (SOAPException e) { throw new SoapException("Failed to wrap the document in a SOAP envelope.", e); } }
MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody soapBody = envelope.getBody(); soapBody.addDocument(soapBodyDoc); **soapBody.addNamespaceDeclaration("", serverURI);**
soapBody.addDocument(soapBodyDoc);
private SOAPMessage convert(Source theResponse, boolean wantSOAP12) { try { SOAPMessage response = null; if (wantSOAP12) { response = SOAPUtil.createSOAP12(); } else { response = SOAPUtil.create(); } Document theResponseDoc = (Document) DocumentUtil.getNodeFromSource(theResponse); response.getSOAPBody().addDocument(theResponseDoc); return response; } catch (Exception e) { throw logger.stsWSError(e); } }
private SOAPMessage convert(Source theResponse, boolean wantSOAP12) { try { SOAPMessage response = null; if (wantSOAP12) { response = SOAPUtil.createSOAP12(); } else { response = SOAPUtil.create(); } Document theResponseDoc = (Document) DocumentUtil.getNodeFromSource(theResponse); response.getSOAPBody().addDocument(theResponseDoc); return response; } catch (Exception e) { throw logger.stsWSError(e); } }
private SOAPMessage convert(Source theResponse, boolean wantSOAP12) { try { SOAPMessage response = null; if (wantSOAP12) { response = SOAPUtil.createSOAP12(); } else { response = SOAPUtil.create(); } Document theResponseDoc = (Document) DocumentUtil.getNodeFromSource(theResponse); response.getSOAPBody().addDocument(theResponseDoc); return response; } catch (Exception e) { throw logger.stsWSError(e); } }
private Object createMessage(String uniqueId, String action, Document payload, boolean isResponse) { SOAPMessage message = null; try { MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); message = messageFactory.createMessage(); message.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true"); createMessageHeader(uniqueId, action, isResponse, message); if (isResponse) { setNamespace(payload, hostInfo.isClient() ? SOAPHostInfo.NAMESPACE_CHARGEBOX : SOAPHostInfo.NAMESPACE_CENTRALSYSTEM); } message.getSOAPBody().addDocument(payload); } catch (Exception e) { logger.warn("createMessage() failed", e); } return message; }
private String createResponse( JaxbCommandsResponse resp ) throws Exception { SOAPMessage msg = msgFactory.createMessage(); // empty response ExecuteResponse execResp = new ExecuteResponse(); execResp.setReturn(resp); JAXBElement<ExecuteResponse> jaxbElem = (new ObjectFactory()).createExecuteResponse(execResp); // marshall Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Marshaller marshaller = JAXBContext.newInstance(ExecuteResponse.class).createMarshaller(); marshaller.marshal(jaxbElem, document); msg.getSOAPBody().addDocument(document); // convert to stream ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); msg.writeTo(outputStream); return new String(outputStream.toByteArray()); } }
public static SOAPMessage buildSOAPMessage(final Document document, final String soapAction) { SOAPMessage soapMessage = null; try { soapMessage = SOAPUtil.getMessageFactory().createMessage(); final MimeHeaders hd = soapMessage.getMimeHeaders(); hd.addHeader("SOAPAction", soapAction); final SOAPPart soapPart = soapMessage.getSOAPPart(); final SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("env", "http://schemas.xmlsoap.org/soap/envelope/"); final SOAPBody body = envelope.getBody(); body.addDocument(document); soapMessage.saveChanges(); } catch (final Exception e) { throw new RuntimeException("Exception while building a SOAPMessage", e); } return soapMessage; }
@Override protected void sendAuthnRequest(HttpFacade httpFacade, SAML2AuthnRequestBuilder authnRequestBuilder, BaseSAML2BindingBuilder binding) { try { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); SOAPEnvelope envelope = message.getSOAPPart().getEnvelope(); envelope.addNamespaceDeclaration(NS_PREFIX_SAML_ASSERTION, JBossSAMLURIConstants.ASSERTION_NSURI.get()); envelope.addNamespaceDeclaration(NS_PREFIX_SAML_PROTOCOL, JBossSAMLURIConstants.PROTOCOL_NSURI.get()); envelope.addNamespaceDeclaration(NS_PREFIX_PAOS_BINDING, JBossSAMLURIConstants.PAOS_BINDING.get()); envelope.addNamespaceDeclaration(NS_PREFIX_PROFILE_ECP, JBossSAMLURIConstants.ECP_PROFILE.get()); createPaosRequestHeader(envelope); createEcpRequestHeader(envelope); SOAPBody body = envelope.getBody(); body.addDocument(binding.postBinding(authnRequestBuilder.toDocument()).getDocument()); message.writeTo(httpFacade.getResponse().getOutputStream()); } catch (Exception e) { throw new RuntimeException("Could not create AuthnRequest.", e); } }