use of org.apache.axiom.soap.SOAPMessage in project webservices-axiom by apache.
the class WSS4JTest method testEncryptHeader.
@Test
public void testEncryptHeader() throws Exception {
Vector<WSEncryptionPart> parts = new Vector<WSEncryptionPart>();
parts.add(new WSEncryptionPart("header", "urn:ns1", "Header"));
WSSecEncrypt encrypt = new WSSecEncrypt();
encrypt.setUserInfo("key2", "password");
encrypt.setEncryptSymmKey(false);
encrypt.setParts(parts);
SOAPMessage message = load("envelope1.xml");
Document doc = (Document) message;
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
encrypt.build(doc, crypto, secHeader);
}
use of org.apache.axiom.soap.SOAPMessage in project webservices-axiom by apache.
the class TestCreateDefaultSOAPMessage method runTest.
@Override
protected void runTest() throws Throwable {
SOAPMessage message = soapFactory.createDefaultSOAPMessage();
SOAPEnvelope env = message.getSOAPEnvelope();
assertNotNull(env);
assertSame(env, message.getFirstOMChild());
assertNull(env.getNextOMSibling());
// Check correct SOAP version
assertEquals(spec.getEnvelopeNamespaceURI(), env.getNamespaceURI());
// Check the children
Iterator<OMNode> it = env.getChildren();
assertTrue(it.hasNext());
OMNode child = it.next();
assertTrue(child instanceof SOAPBody);
assertNull(((SOAPBody) child).getFirstOMChild());
assertFalse(it.hasNext());
}
use of org.apache.axiom.soap.SOAPMessage in project webservices-axiom by apache.
the class TestClone method runTest.
@Override
protected void runTest() throws Throwable {
SOAPMessage message = soapFactory.createSOAPMessage();
message.addChild(soapFactory.getDefaultEnvelope());
OMCloneOptions options = new OMCloneOptions();
options.setPreserveModel(preserveModel);
OMInformationItem clone = message.clone(options);
if (preserveModel) {
assertTrue(clone instanceof SOAPMessage);
} else {
assertTrue(clone instanceof OMDocument);
assertFalse(clone instanceof SOAPMessage);
}
OMElement envelope = ((OMDocument) clone).getOMDocumentElement();
if (preserveModel) {
assertTrue(envelope instanceof SOAPEnvelope);
} else {
assertFalse(envelope instanceof SOAPEnvelope);
}
assertEquals("Envelope", envelope.getLocalName());
assertEquals(spec.getEnvelopeNamespaceURI(), envelope.getNamespaceURI());
}
use of org.apache.axiom.soap.SOAPMessage in project webservices-axiom by apache.
the class TestCloneIncomplete method runTest.
@Override
protected void runTest() throws Throwable {
SOAPMessage message = SOAPSampleSet.WSA.getMessage(spec).getAdapter(SOAPSampleAdapter.class).getSOAPMessage(metaFactory);
OMCloneOptions options = new OMCloneOptions();
options.setPreserveModel(preserveModel);
OMInformationItem clone = message.clone(options);
if (preserveModel) {
assertTrue(clone instanceof SOAPMessage);
assertSame(soapFactory, clone.getOMFactory());
} else {
assertTrue(clone instanceof OMDocument);
assertFalse(clone instanceof SOAPMessage);
}
}
use of org.apache.axiom.soap.SOAPMessage in project webservices-axiom by apache.
the class TestGetOMFactoryWithParser method runTest.
@Override
protected void runTest() throws Throwable {
SOAPMessage message = SOAPSampleSet.WSA.getMessage(spec).getAdapter(SOAPSampleAdapter.class).getSOAPMessage(metaFactory);
assertSame(soapFactory, message.getOMFactory());
}
Aggregations