Search in sources :

Example 61 with SOAPEnvelope

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

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

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

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

the class TestGetHeader method runTest.

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

Example 65 with SOAPEnvelope

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

the class TestGetOrCreateHeader method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
    SOAPHeader header = (SOAPHeader) envelope.getFirstOMChild();
    assertSame(header, envelope.getOrCreateHeader());
}
Also used : SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Aggregations

SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)105 OMElement (org.apache.axiom.om.OMElement)32 SOAPBody (org.apache.axiom.soap.SOAPBody)24 OMNamespace (org.apache.axiom.om.OMNamespace)22 SOAPHeader (org.apache.axiom.soap.SOAPHeader)20 SOAPFactory (org.apache.axiom.soap.SOAPFactory)18 QName (javax.xml.namespace.QName)16 SOAPFault (org.apache.axiom.soap.SOAPFault)14 ByteArrayInputStream (java.io.ByteArrayInputStream)12 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)12 OMNode (org.apache.axiom.om.OMNode)11 SOAPModelBuilder (org.apache.axiom.soap.SOAPModelBuilder)11 MessageContext (org.apache.axis2.context.MessageContext)10 SOAPFaultCode (org.apache.axiom.soap.SOAPFaultCode)8 InputStream (java.io.InputStream)7 XMLStreamException (javax.xml.stream.XMLStreamException)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 StringReader (java.io.StringReader)6 DataHandler (javax.activation.DataHandler)6 OMException (org.apache.axiom.om.OMException)6