Search in sources :

Example 16 with SOAPBody

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

the class TestGetAllDetailEntries method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPBody body = soapFactory.createSOAPBody(envelope);
    SOAPFault fault = soapFactory.createSOAPFault(body);
    SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail(fault);
    OMNamespace omNamespace = soapFactory.createOMNamespace("http://www.test.org", "test");
    Iterator<OMElement> iterator = soapFaultDetail.getAllDetailEntries();
    assertFalse("SOAP Fault Detail Test : - After creating SOAP11FaultDetail element, it has DetailEntries", iterator.hasNext());
    soapFaultDetail.addDetailEntry(soapFactory.createOMElement("DetailEntry", omNamespace));
    iterator = soapFaultDetail.getAllDetailEntries();
    OMElement detailEntry = iterator.next();
    assertNotNull("SOAP Fault Detail Test : - After calling addDetailEntry method, getAllDetailEntries method returns empty iterator", detailEntry);
    assertEquals("SOAP Fault Detail Test : - detailEntry local name mismatch", "DetailEntry", detailEntry.getLocalName());
    assertEquals("SOAP Fault Detail Test : - detailEntry namespace uri mismatch", "http://www.test.org", detailEntry.getNamespace().getNamespaceURI());
    assertFalse("SOAP Fault Detail Test : - After calling addDetailEntry method once, getAllDetailEntries method returns an iterator with two objects", iterator.hasNext());
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) OMNamespace(org.apache.axiom.om.OMNamespace) SOAPFaultDetail(org.apache.axiom.soap.SOAPFaultDetail) SOAPFault(org.apache.axiom.soap.SOAPFault) OMElement(org.apache.axiom.om.OMElement) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 17 with SOAPBody

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

the class TestSerialization method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPBody body = soapFactory.createSOAPBody(envelope);
    SOAPFault fault = soapFactory.createSOAPFault(body);
    SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail(fault);
    OMNamespace omNamespace = soapFactory.createOMNamespace("http://www.test.org", "test");
    soapFaultDetail.addDetailEntry(soapFactory.createOMElement("DetailEntry1", omNamespace));
    soapFaultDetail.addDetailEntry(soapFactory.createOMElement("DetailEntry2", omNamespace));
    StringWriter out = new StringWriter();
    soapFaultDetail.serialize(out);
    String msg = out.toString();
    assertTrue(msg.indexOf("DetailEntry1") != -1);
    assertTrue(msg.indexOf("DetailEntry2") != -1);
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) OMNamespace(org.apache.axiom.om.OMNamespace) StringWriter(java.io.StringWriter) SOAPFaultDetail(org.apache.axiom.soap.SOAPFaultDetail) SOAPFault(org.apache.axiom.soap.SOAPFault) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 18 with SOAPBody

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

the class TestCloneWithSourcedElement2 method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope sourceEnv = soapFactory.getDefaultEnvelope();
    SOAPBody body = sourceEnv.getBody();
    SOAPHeader header = sourceEnv.getHeader();
    // Create a header OMSE
    OMDataSource dsHdr = new StringOMDataSource("<hdr:myheader xmlns:hdr=\"urn://test\">Hello World</hdr:myheader>");
    OMNamespace hdrNS = header.getOMFactory().createOMNamespace("urn://test", "hdr");
    SOAPFactory sf = (SOAPFactory) header.getOMFactory();
    SOAPHeaderBlock shb = sf.createSOAPHeaderBlock("myheader", hdrNS, dsHdr);
    // test setting processing flag
    shb.setProcessed();
    header.addChild(shb);
    // Create a payload
    OMDataSource ds = 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(ds, "payload", ns);
    body.addChild(omse);
    copyAndCheck(sourceEnv);
    // The source SOAPHeaderBlock should not be expanded in the process
    assertFalse(shb.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) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) OMSourcedElement(org.apache.axiom.om.OMSourcedElement) SOAPHeader(org.apache.axiom.soap.SOAPHeader) SOAPFactory(org.apache.axiom.soap.SOAPFactory)

Example 19 with SOAPBody

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

the class TestGetBody method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
    SOAPBody body = envelope.getBody();
    assertEquals("Body Test : - Body local name mismatch", SOAPConstants.BODY_LOCAL_NAME, body.getLocalName());
    assertEquals("Body Test : - Body namespace mismatch", spec.getEnvelopeNamespaceURI(), body.getNamespace().getNamespaceURI());
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 20 with SOAPBody

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

the class TestGetBodyWithParser method runTest.

@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
    SOAPBody body = envelope.getBody();
    assertEquals("Body Test : - Body local name mismatch", SOAPConstants.BODY_LOCAL_NAME, body.getLocalName());
    assertEquals("Body Test : - Body namespace mismatch", spec.getEnvelopeNamespaceURI(), body.getNamespace().getNamespaceURI());
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody)

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