Search in sources :

Example 1 with SOAPMessage

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);
}
Also used : WSEncryptionPart(org.apache.ws.security.WSEncryptionPart) WSSecHeader(org.apache.ws.security.message.WSSecHeader) WSSecEncrypt(org.apache.ws.security.message.WSSecEncrypt) Document(org.w3c.dom.Document) Vector(java.util.Vector) SOAPMessage(org.apache.axiom.soap.SOAPMessage) Test(org.junit.Test)

Example 2 with SOAPMessage

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());
}
Also used : OMNode(org.apache.axiom.om.OMNode) SOAPBody(org.apache.axiom.soap.SOAPBody) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPMessage(org.apache.axiom.soap.SOAPMessage)

Example 3 with SOAPMessage

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());
}
Also used : OMInformationItem(org.apache.axiom.om.OMInformationItem) OMCloneOptions(org.apache.axiom.om.OMCloneOptions) OMElement(org.apache.axiom.om.OMElement) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPMessage(org.apache.axiom.soap.SOAPMessage) OMDocument(org.apache.axiom.om.OMDocument)

Example 4 with SOAPMessage

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);
    }
}
Also used : OMInformationItem(org.apache.axiom.om.OMInformationItem) OMCloneOptions(org.apache.axiom.om.OMCloneOptions) SOAPSampleAdapter(org.apache.axiom.ts.soap.SOAPSampleAdapter) SOAPMessage(org.apache.axiom.soap.SOAPMessage) OMDocument(org.apache.axiom.om.OMDocument)

Example 5 with 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());
}
Also used : SOAPSampleAdapter(org.apache.axiom.ts.soap.SOAPSampleAdapter) SOAPMessage(org.apache.axiom.soap.SOAPMessage)

Aggregations

SOAPMessage (org.apache.axiom.soap.SOAPMessage)16 OMDocument (org.apache.axiom.om.OMDocument)4 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)4 Document (org.w3c.dom.Document)4 OMElement (org.apache.axiom.om.OMElement)3 SOAPSampleAdapter (org.apache.axiom.ts.soap.SOAPSampleAdapter)3 OMCloneOptions (org.apache.axiom.om.OMCloneOptions)2 OMInformationItem (org.apache.axiom.om.OMInformationItem)2 OMNode (org.apache.axiom.om.OMNode)2 WSSecHeader (org.apache.ws.security.message.WSSecHeader)2 InputSource (org.xml.sax.InputSource)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Vector (java.util.Vector)1 QName (javax.xml.namespace.QName)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 DOMSource (javax.xml.transform.dom.DOMSource)1 SAXSource (javax.xml.transform.sax.SAXSource)1 OMComment (org.apache.axiom.om.OMComment)1