Search in sources :

Example 1 with SOAPBody

use of org.apache.axiom.soap.SOAPBody 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 2 with SOAPBody

use of org.apache.axiom.soap.SOAPBody in project webservices-axiom by apache.

the class TestCreateSOAPFaultWithException method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPBody body = withParent ? soapFactory.getDefaultEnvelope().getBody() : null;
    SOAPFault fault = soapFactory.createSOAPFault(body, new Exception("Testing soap fault"));
    if (body != null) {
        assertThat(body.hasFault()).isTrue();
        assertThat(body.getFault()).isSameAs(fault);
    }
    assertThat(fault.isComplete()).isTrue();
    SOAPFaultDetail detail = fault.getDetail();
    assertThat(detail).isNotNull();
    Iterator<OMElement> it = detail.getAllDetailEntries();
    assertThat(it.hasNext()).isTrue();
    OMElement entry = it.next();
    assertThat(entry.getQName()).isEqualTo(new QName(SOAPConstants.SOAP_FAULT_DETAIL_EXCEPTION_ENTRY));
    assertThat(entry.getText()).contains("Testing soap fault");
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) QName(javax.xml.namespace.QName) SOAPFaultDetail(org.apache.axiom.soap.SOAPFaultDetail) SOAPFault(org.apache.axiom.soap.SOAPFault) OMElement(org.apache.axiom.om.OMElement)

Example 3 with SOAPBody

use of org.apache.axiom.soap.SOAPBody in project webservices-axiom by apache.

the class TestGetDefaultEnvelope method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope env = soapFactory.getDefaultEnvelope();
    // Check correct SOAP version
    assertEquals(spec.getEnvelopeNamespaceURI(), env.getNamespaceURI());
    // getDefaultEnvelope doesn't create a SOAPMessage/OMDocument
    assertNull(env.getParent());
    // Check the children
    Iterator<OMNode> it = env.getChildren();
    assertTrue(it.hasNext());
    OMNode child = it.next();
    assertTrue(child instanceof SOAPHeader);
    assertNull(((SOAPHeader) child).getFirstOMChild());
    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) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 4 with SOAPBody

use of org.apache.axiom.soap.SOAPBody in project webservices-axiom by apache.

the class TestDiscardPartiallyBuilt method runTest.

@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
    SOAPHeader header = envelope.getHeader();
    OMElement from = header.getFirstChildWithName(new QName("http://www.w3.org/2005/08/addressing", "ReplyTo"));
    from.getFirstElement().getFirstOMChild();
    // Just in case getFirstChildWithName or getFirstElement did stupid things
    assertFalse(from.isComplete());
    header.discard();
    OMElement body = envelope.getFirstElement();
    assertTrue(body instanceof SOAPBody);
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 5 with SOAPBody

use of org.apache.axiom.soap.SOAPBody in project webservices-axiom by apache.

the class TestCloneWithSourcedElement1 method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope sourceEnv = soapFactory.getDefaultEnvelope();
    SOAPBody body = sourceEnv.getBody();
    // Create a payload
    OMDataSource bads = new StringOMDataSource("<tns:payload xmlns:tns=\"urn://test\">Hello World</tns:payload>");
    OMNamespace ns = body.getOMFactory().createOMNamespace("urn://test", "tns");
    OMSourcedElement omse = body.getOMFactory().createOMElement(bads, "payload", ns);
    body.addChild(omse);
    copyAndCheck(sourceEnv);
    assertFalse(omse.isExpanded());
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) OMNamespace(org.apache.axiom.om.OMNamespace) OMDataSource(org.apache.axiom.om.OMDataSource) StringOMDataSource(org.apache.axiom.om.ds.StringOMDataSource) StringOMDataSource(org.apache.axiom.om.ds.StringOMDataSource) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) OMSourcedElement(org.apache.axiom.om.OMSourcedElement)

Aggregations

SOAPBody (org.apache.axiom.soap.SOAPBody)36 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)23 OMElement (org.apache.axiom.om.OMElement)13 SOAPFault (org.apache.axiom.soap.SOAPFault)7 SOAPFaultDetail (org.apache.axiom.soap.SOAPFaultDetail)7 OMNamespace (org.apache.axiom.om.OMNamespace)6 SOAPHeader (org.apache.axiom.soap.SOAPHeader)5 StringReader (java.io.StringReader)4 QName (javax.xml.namespace.QName)4 OMNode (org.apache.axiom.om.OMNode)4 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)4 OMDataSource (org.apache.axiom.om.OMDataSource)3 OMSourcedElement (org.apache.axiom.om.OMSourcedElement)3 StringOMDataSource (org.apache.axiom.om.ds.StringOMDataSource)3 SOAPFactory (org.apache.axiom.soap.SOAPFactory)3 SOAPFaultCode (org.apache.axiom.soap.SOAPFaultCode)3 SOAPFaultReason (org.apache.axiom.soap.SOAPFaultReason)3 SOAPFaultRole (org.apache.axiom.soap.SOAPFaultRole)3 StringWriter (java.io.StringWriter)2 OMAttribute (org.apache.axiom.om.OMAttribute)2