javax.xml.soap.MessageFactory Java Examples
The following examples show how to use
javax.xml.soap.MessageFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeviceDiscovery.java From onvif with Apache License 2.0 | 6 votes |
private static Collection<String> parseSoapResponseForUrls(byte[] data) throws SOAPException, IOException { // System.out.println(new String(data)); final Collection<String> urls = new ArrayList<>(); MessageFactory factory = MessageFactory.newInstance(WS_DISCOVERY_SOAP_VERSION); final MimeHeaders headers = new MimeHeaders(); headers.addHeader("Content-type", WS_DISCOVERY_CONTENT_TYPE); SOAPMessage message = factory.createMessage(headers, new ByteArrayInputStream(data)); SOAPBody body = message.getSOAPBody(); for (Node node : getNodeMatching(body, ".*:XAddrs")) { if (node.getTextContent().length() > 0) { urls.addAll(Arrays.asList(node.getTextContent().split(" "))); } } return urls; }
Example #2
Source File: SAAJMetaFactoryImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
protected MessageFactory newMessageFactory(String protocol) throws SOAPException { if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl(); } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl(); } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl(); } else { log.log( Level.SEVERE, "SAAJ0569.soap.unknown.protocol", new Object[] {protocol, "MessageFactory"}); throw new SOAPException("Unknown Protocol: " + protocol + " specified for creating MessageFactory"); } }
Example #3
Source File: XmlTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private SOAPMessage createMessage(MessageFactory mf) throws SOAPException, IOException { SOAPMessage msg = mf.createMessage(); SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope(); Name name = envelope.createName("hello", "ex", "http://example.com"); envelope.getBody().addChildElement(name).addTextNode("THERE!"); String s = "<root><hello>THERE!</hello></root>"; AttachmentPart ap = msg.createAttachmentPart( new StreamSource(new ByteArrayInputStream(s.getBytes())), "text/xml" ); msg.addAttachmentPart(ap); msg.saveChanges(); return msg; }
Example #4
Source File: SAAJMetaFactoryImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override protected MessageFactory newMessageFactory(String protocol) throws SOAPException { if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl(); } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl(); } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl(); } else { log.log( Level.SEVERE, "SAAJ0569.soap.unknown.protocol", new Object[] {protocol, "MessageFactory"}); throw new SOAPException("Unknown Protocol: " + protocol + " specified for creating MessageFactory"); } }
Example #5
Source File: SAAJMetaFactoryImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
protected MessageFactory newMessageFactory(String protocol) throws SOAPException { if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl(); } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl(); } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl(); } else { log.log( Level.SEVERE, "SAAJ0569.soap.unknown.protocol", new Object[] {protocol, "MessageFactory"}); throw new SOAPException("Unknown Protocol: " + protocol + " specified for creating MessageFactory"); } }
Example #6
Source File: SAAJMetaFactoryImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
protected MessageFactory newMessageFactory(String protocol) throws SOAPException { if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl(); } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl(); } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl(); } else { log.log( Level.SEVERE, "SAAJ0569.soap.unknown.protocol", new Object[] {protocol, "MessageFactory"}); throw new SOAPException("Unknown Protocol: " + protocol + " specified for creating MessageFactory"); } }
Example #7
Source File: SAAJMetaFactoryImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
protected MessageFactory newMessageFactory(String protocol) throws SOAPException { if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl(); } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl(); } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl(); } else { log.log( Level.SEVERE, "SAAJ0569.soap.unknown.protocol", new Object[] {protocol, "MessageFactory"}); throw new SOAPException("Unknown Protocol: " + protocol + " specified for creating MessageFactory"); } }
Example #8
Source File: SAAJMetaFactoryImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
protected MessageFactory newMessageFactory(String protocol) throws SOAPException { if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl(); } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl(); } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl(); } else { log.log( Level.SEVERE, "SAAJ0569.soap.unknown.protocol", new Object[] {protocol, "MessageFactory"}); throw new SOAPException("Unknown Protocol: " + protocol + " specified for creating MessageFactory"); } }
Example #9
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static SOAPMessage createSoapMessage() throws SOAPException, UnsupportedEncodingException { String xml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" +"<SOAP-ENV:Body/></SOAP-ENV:Envelope>"; MessageFactory mFactory = MessageFactory.newInstance(); SOAPMessage msg = mFactory.createMessage(); msg.getSOAPPart().setContent(new StreamSource(new ByteArrayInputStream(xml.getBytes("utf-8")))); return msg; }
Example #10
Source File: SaajEmptyNamespaceTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static SOAPMessage createSoapMessage() throws SOAPException, UnsupportedEncodingException { String xml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" +"<SOAP-ENV:Body/></SOAP-ENV:Envelope>"; MessageFactory mFactory = MessageFactory.newInstance(); SOAPMessage msg = mFactory.createMessage(); msg.getSOAPPart().setContent(new StreamSource(new ByteArrayInputStream(xml.getBytes("utf-8")))); return msg; }
Example #11
Source File: SAAJFactoryTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected void test(String[] args) { if (args.length < 5) throw new IllegalArgumentException("Incorrect test setup. Required 5 arguments: \n" + " 1. expected factory class (if any)\n" + " 2. expected \n" + " 3. scenario name\n" + " 4. jdk/conf configured provider class name\n" + " 5. service loader provider class name"); scenario = args[2]; // scenario name prepare(args[3], args[4]); // jdk/conf class, service loader class try { MessageFactory factory = factory(); assertTrue(factory != null, "No factory found."); String className = factory.getClass().getName(); assertTrue(args[0].equals(className), "Incorrect factory: [" + className + "], Expected: [" + args[0] + "]"); } catch (Throwable throwable) { String expectedExceptionClass = args[1]; String throwableClass = throwable.getClass().getName(); boolean correctException = throwableClass.equals(expectedExceptionClass); if (!correctException) { throwable.printStackTrace(); } assertTrue(correctException, "Got unexpected exception: [" + throwableClass + "], expected: [" + expectedExceptionClass + "]"); } finally { cleanResource(providersFile); cleanResource(providersDir); // unsafe; not running: // cleanResource(jdkFile); } }
Example #12
Source File: SaajEmptyNamespaceTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static SOAPMessage createSoapMessage() throws SOAPException, UnsupportedEncodingException { String xml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" +"<SOAP-ENV:Body/></SOAP-ENV:Envelope>"; MessageFactory mFactory = MessageFactory.newInstance(); SOAPMessage msg = mFactory.createMessage(); msg.getSOAPPart().setContent(new StreamSource(new ByteArrayInputStream(xml.getBytes("utf-8")))); return msg; }
Example #13
Source File: MailTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
void addSoapAttachement() { try { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); AttachmentPart a = message.createAttachmentPart(); a.setContentType("binary/octet-stream"); message.addAttachmentPart(a); } catch (SOAPException e) { e.printStackTrace(); } }
Example #14
Source File: XmlTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void test() throws Exception { File file = new File("message.xml"); file.deleteOnExit(); MessageFactory mf = MessageFactory.newInstance(); SOAPMessage msg = createMessage(mf); // Save the soap message to file try (FileOutputStream sentFile = new FileOutputStream(file)) { msg.writeTo(sentFile); } // See if we get the image object back try (FileInputStream fin = new FileInputStream(file)) { SOAPMessage newMsg = mf.createMessage(msg.getMimeHeaders(), fin); newMsg.writeTo(new ByteArrayOutputStream()); Iterator<?> i = newMsg.getAttachments(); while (i.hasNext()) { AttachmentPart att = (AttachmentPart) i.next(); Object obj = att.getContent(); if (!(obj instanceof StreamSource)) { fail("Got incorrect attachment type [" + obj.getClass() + "], " + "expected [javax.xml.transform.stream.StreamSource]"); } } } }
Example #15
Source File: MailTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void addSoapAttachement() { try { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); AttachmentPart a = message.createAttachmentPart(); a.setContentType("binary/octet-stream"); message.addAttachmentPart(a); } catch (SOAPException e) { e.printStackTrace(); } }
Example #16
Source File: MailTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void addSoapAttachement() { try { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); AttachmentPart a = message.createAttachmentPart(); a.setContentType("binary/octet-stream"); message.addAttachmentPart(a); } catch (SOAPException e) { e.printStackTrace(); } }
Example #17
Source File: AbstractSecurityTest.java From steady with Apache License 2.0 | 5 votes |
/** * Creates a {@link SoapMessage} from the contents of a document. * @param doc the document containing the SOAP content. */ protected SoapMessage getSoapMessageForDom(Document doc) throws SOAPException { SOAPMessage saajMsg = MessageFactory.newInstance().createMessage(); SOAPPart part = saajMsg.getSOAPPart(); part.setContent(new DOMSource(doc)); saajMsg.saveChanges(); SoapMessage msg = new SoapMessage(new MessageImpl()); Exchange ex = new ExchangeImpl(); ex.setInMessage(msg); msg.setContent(SOAPMessage.class, saajMsg); return msg; }
Example #18
Source File: MailTest.java From hottub with GNU General Public License v2.0 | 5 votes |
void addSoapAttachement() { try { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); AttachmentPart a = message.createAttachmentPart(); a.setContentType("binary/octet-stream"); message.addAttachmentPart(a); } catch (SOAPException e) { e.printStackTrace(); } }
Example #19
Source File: MdwRpcWebServiceAdapter.java From mdw with Apache License 2.0 | 5 votes |
/** * Populate the SOAP request message. */ protected SOAPMessage createSoapRequest(Object requestObj) throws ActivityException { try { MessageFactory messageFactory = getSoapMessageFactory(); SOAPMessage soapMessage = messageFactory.createMessage(); Map<Name,String> soapReqHeaders = getSoapRequestHeaders(); if (soapReqHeaders != null) { SOAPHeader header = soapMessage.getSOAPHeader(); for (Name name : soapReqHeaders.keySet()) { header.addHeaderElement(name).setTextContent(soapReqHeaders.get(name)); } } SOAPBody soapBody = soapMessage.getSOAPBody(); Document requestDoc = null; if (requestObj instanceof String) { requestDoc = DomHelper.toDomDocument((String)requestObj); } else { Variable reqVar = getProcessDefinition().getVariable(getAttributeValue(REQUEST_VARIABLE)); XmlDocumentTranslator docRefTrans = (XmlDocumentTranslator)getPackage().getTranslator(reqVar.getType()); requestDoc = docRefTrans.toDomDocument(requestObj); } SOAPBodyElement bodyElem = soapBody.addBodyElement(getOperation()); String requestLabel = getRequestLabelPartName(); if (requestLabel != null) { SOAPElement serviceNameElem = bodyElem.addChildElement(requestLabel); serviceNameElem.addTextNode(getRequestLabel()); } SOAPElement requestDetailsElem = bodyElem.addChildElement(getRequestPartName()); requestDetailsElem.addTextNode("<![CDATA[" + DomHelper.toXml(requestDoc) + "]]>"); return soapMessage; } catch (Exception ex) { throw new ActivityException(ex.getMessage(), ex); } }
Example #20
Source File: MailTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void addSoapAttachement() { try { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); AttachmentPart a = message.createAttachmentPart(); a.setContentType("binary/octet-stream"); message.addAttachmentPart(a); } catch (SOAPException e) { e.printStackTrace(); } }
Example #21
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static SOAPMessage createSoapMessage() throws SOAPException, UnsupportedEncodingException { String xml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" +"<SOAP-ENV:Body/></SOAP-ENV:Envelope>"; MessageFactory mFactory = MessageFactory.newInstance(); SOAPMessage msg = mFactory.createMessage(); msg.getSOAPPart().setContent(new StreamSource(new ByteArrayInputStream(xml.getBytes("utf-8")))); return msg; }
Example #22
Source File: SaajEmptyNamespaceTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static SOAPMessage createSoapMessage() throws SOAPException, UnsupportedEncodingException { String xml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" +"<SOAP-ENV:Body/></SOAP-ENV:Envelope>"; MessageFactory mFactory = MessageFactory.newInstance(); SOAPMessage msg = mFactory.createMessage(); msg.getSOAPPart().setContent(new StreamSource(new ByteArrayInputStream(xml.getBytes("utf-8")))); return msg; }
Example #23
Source File: MailTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
void addSoapAttachement() { try { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); AttachmentPart a = message.createAttachmentPart(); a.setContentType("binary/octet-stream"); message.addAttachmentPart(a); } catch (SOAPException e) { e.printStackTrace(); } }
Example #24
Source File: ArcherAuthenticatingRestConnection.java From FortifyBugTrackerUtility with MIT License | 5 votes |
public Long addValueToValuesList(Long valueListId, String value) { LOG.info("[Archer] Adding value '"+value+"' to value list id "+valueListId); // Adding items to value lists is not supported via REST API, so we need to revert to SOAP API // TODO Simplify this method? // TODO Make this method more fail-safe (like checking for the correct response element)? Long result = null; try { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody body = envelope.getBody(); SOAPElement bodyElement = body.addChildElement(envelope.createName("CreateValuesListValue", "", "http://archer-tech.com/webservices/")); bodyElement.addChildElement("sessionToken").addTextNode(tokenProviderRest.getToken()); bodyElement.addChildElement("valuesListId").addTextNode(valueListId+""); bodyElement.addChildElement("valuesListValueName").addTextNode(value); message.saveChanges(); SOAPMessage response = executeRequest(HttpMethod.POST, getBaseResource().path("/ws/field.asmx") .request() .header("SOAPAction", "\"http://archer-tech.com/webservices/CreateValuesListValue\"") .accept("text/xml"), Entity.entity(message, "text/xml"), SOAPMessage.class); @SuppressWarnings("unchecked") Iterator<Object> it = response.getSOAPBody().getChildElements(); while (it.hasNext()){ Object o = it.next(); if ( o instanceof SOAPElement ) { result = new Long(((SOAPElement)o).getTextContent()); } } System.out.println(response); } catch (SOAPException e) { throw new RuntimeException("Error executing SOAP request", e); } return result; }
Example #25
Source File: SaajEmptyNamespaceTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static SOAPMessage createSoapMessage() throws SOAPException, UnsupportedEncodingException { String xml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" +"<SOAP-ENV:Body/></SOAP-ENV:Envelope>"; MessageFactory mFactory = MessageFactory.newInstance(); SOAPMessage msg = mFactory.createMessage(); msg.getSOAPPart().setContent(new StreamSource(new ByteArrayInputStream(xml.getBytes("utf-8")))); return msg; }
Example #26
Source File: MailTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
void addSoapAttachement() { try { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); AttachmentPart a = message.createAttachmentPart(); a.setContentType("binary/octet-stream"); message.addAttachmentPart(a); } catch (SOAPException e) { e.printStackTrace(); } }
Example #27
Source File: AbstractSecurityTest.java From steady with Apache License 2.0 | 5 votes |
/** * Creates a {@link SoapMessage} from the contents of a document. * @param doc the document containing the SOAP content. */ protected SoapMessage getSoapMessageForDom(Document doc) throws SOAPException { SOAPMessage saajMsg = MessageFactory.newInstance().createMessage(); SOAPPart part = saajMsg.getSOAPPart(); part.setContent(new DOMSource(doc)); saajMsg.saveChanges(); SoapMessage msg = new SoapMessage(new MessageImpl()); Exchange ex = new ExchangeImpl(); ex.setInMessage(msg); msg.setContent(SOAPMessage.class, saajMsg); return msg; }
Example #28
Source File: DocumentWebServiceAdapter.java From mdw with Apache License 2.0 | 5 votes |
/** * Create the SOAP request object based on the document variable value. */ protected SOAPMessage createSoapRequest(Object requestObj) throws ActivityException { try { MessageFactory messageFactory = getSoapMessageFactory(); SOAPMessage soapMessage = messageFactory.createMessage(); Map<Name,String> soapReqHeaders = getSoapRequestHeaders(); if (soapReqHeaders != null) { SOAPHeader header = soapMessage.getSOAPHeader(); for (Name name : soapReqHeaders.keySet()) { header.addHeaderElement(name).setTextContent(soapReqHeaders.get(name)); } } SOAPBody soapBody = soapMessage.getSOAPBody(); Document requestDoc = null; if (requestObj instanceof String) { requestDoc = DomHelper.toDomDocument((String)requestObj); soapBody.addDocument(requestDoc); } else { Variable reqVar = getProcessDefinition().getVariable(getAttributeValue(REQUEST_VARIABLE)); XmlDocumentTranslator docRefTrans = (XmlDocumentTranslator)getPackage().getTranslator(reqVar.getType()); requestDoc = docRefTrans.toDomDocument(requestObj); Document copiedDocument = DomHelper.copyDomDocument(requestDoc); soapBody.addDocument(copiedDocument); } return soapMessage; } catch (Exception ex) { throw new ActivityException(ex.getMessage(), ex); } }
Example #29
Source File: AbstractSecurityTest.java From steady with Apache License 2.0 | 5 votes |
/** * Creates a {@link SoapMessage} from the contents of a document. * @param doc the document containing the SOAP content. */ protected SoapMessage getSoapMessageForDom(Document doc) throws SOAPException { SOAPMessage saajMsg = MessageFactory.newInstance().createMessage(); SOAPPart part = saajMsg.getSOAPPart(); part.setContent(new DOMSource(doc)); saajMsg.saveChanges(); SoapMessage msg = new SoapMessage(new MessageImpl()); Exchange ex = new ExchangeImpl(); ex.setInMessage(msg); msg.setContent(SOAPMessage.class, saajMsg); return msg; }
Example #30
Source File: SamlTokenTest.java From steady with Apache License 2.0 | 4 votes |
private SoapMessage makeInvocation( Map<String, Object> outProperties, List<String> xpaths, Map<String, Object> inProperties, Map<String, String> inMessageProperties ) throws Exception { Document doc = readDocument("wsse-request-clean.xml"); WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(); PhaseInterceptor<SoapMessage> handler = ohandler.createEndingInterceptor(); SoapMessage msg = new SoapMessage(new MessageImpl()); Exchange ex = new ExchangeImpl(); ex.setInMessage(msg); SOAPMessage saajMsg = MessageFactory.newInstance().createMessage(); SOAPPart part = saajMsg.getSOAPPart(); part.setContent(new DOMSource(doc)); saajMsg.saveChanges(); msg.setContent(SOAPMessage.class, saajMsg); for (String key : outProperties.keySet()) { msg.put(key, outProperties.get(key)); } handler.handleMessage(msg); doc = part; for (String xpath : xpaths) { assertValid(xpath, doc); } byte[] docbytes = getMessageBytes(doc); XMLStreamReader reader = StaxUtils.createXMLStreamReader(new ByteArrayInputStream(docbytes)); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setIgnoringComments(false); dbf.setIgnoringElementContentWhitespace(true); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new NullResolver()); doc = StaxUtils.read(db, reader, false); WSS4JInInterceptor inHandler = new WSS4JInInterceptor(inProperties); SoapMessage inmsg = new SoapMessage(new MessageImpl()); inmsg.put(SecurityConstants.SAML_ROLE_ATTRIBUTENAME, "role"); for (String inMessageProperty : inMessageProperties.keySet()) { inmsg.put(inMessageProperty, inMessageProperties.get(inMessageProperty)); } ex.setInMessage(inmsg); inmsg.setContent(SOAPMessage.class, saajMsg); inHandler.handleMessage(inmsg); return inmsg; }