Search in sources :

Example 6 with SOAPBody

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

the class TestSerializeAndConsumeWithOMSEInBody method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPBody body = soapFactory.createSOAPBody();
    envelope.addChild(body);
    OMNamespace ns = soapFactory.createOMNamespace("http://ns1", "d");
    OMElement payload = soapFactory.createOMElement(new DummySource(), "dummy", ns);
    // This line will cause NoSuchElementException
    payload.setNamespace(ns);
    body.addChild(payload);
    StringWriter writer = new StringWriter();
    envelope.serializeAndConsume(writer);
//        System.out.println(writer);
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) OMNamespace(org.apache.axiom.om.OMNamespace) StringWriter(java.io.StringWriter) OMElement(org.apache.axiom.om.OMElement) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 7 with SOAPBody

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

the class TestHasFaultWithOMSEUnknownName method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
    SOAPBody body = envelope.getBody();
    OMSourcedElement element = soapFactory.createOMElement(new StringOMDataSource("<ns:root xmlns:ns='urn:ns'/>"));
    body.addChild(element);
    assertFalse(body.hasFault());
    assertFalse(element.isExpanded());
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) StringOMDataSource(org.apache.axiom.om.ds.StringOMDataSource) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) OMSourcedElement(org.apache.axiom.om.OMSourcedElement)

Example 8 with SOAPBody

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

the class TestAddFault2 method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPBody body = soapFactory.createSOAPBody(envelope);
    body.addFault(soapFactory.createSOAPFault());
    assertTrue("Body Test:- After calling addFault method, SOAP body has no fault", body.hasFault());
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 9 with SOAPBody

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

the class TestGetFaultWithParser method runTest.

@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
    SOAPBody body = envelope.getBody();
    assertNotNull("Body Test With parser :- getFault method returns null", body.getFault());
    assertEquals("Body Test With parser : - SOAP fault name mismatch", SOAPConstants.SOAPFAULT_LOCAL_NAME, body.getFault().getLocalName());
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody)

Example 10 with SOAPBody

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

the class TestHasFault method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPBody body = soapFactory.createSOAPBody(envelope);
    assertFalse("Body Test:- After creating a soap body it has a fault", body.hasFault());
    body.addFault(new Exception("This an exception for testing"));
    assertTrue("Body Test:- After calling addFault method, hasFault method returns false", body.hasFault());
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

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