Search in sources :

Example 16 with SOAPEnvelope

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

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

the class TestGetValueAsQName method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope env = soapFactory.getDefaultEnvelope();
    SOAPFault fault = soapFactory.createSOAPFault(env.getBody());
    SOAPFaultCode code = soapFactory.createSOAPFaultCode(fault);
    QName value = new QName("urn:test", "myFaultCode");
    code.setValue(value);
    assertEquals(value, code.getValueAsQName());
}
Also used : SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) QName(javax.xml.namespace.QName) SOAPFault(org.apache.axiom.soap.SOAPFault) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 18 with SOAPEnvelope

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

the class TestAddHeaderBlock method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope();
    SOAPHeader soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
    OMNamespace namespace = soapFactory.createOMNamespace("http://www.example.org", "test");
    SOAPHeaderBlock headerBlock1 = soapHeader.addHeaderBlock("echoOk1", namespace);
    SOAPHeaderBlock headerBlock2 = soapHeader.addHeaderBlock("echoOk2", namespace);
    Iterator<OMNode> iterator = soapHeader.getChildren();
    assertSame(headerBlock1, iterator.next());
    assertSame(soapHeader, headerBlock1.getParent());
    assertNotNull("SOAP Header Test : - After calling addHeaderBlock method twice, getChildren method returns empty iterator", headerBlock1);
    assertEquals("SOAP Header Test : - HeaderBlock1 local name mismatch", "echoOk1", headerBlock1.getLocalName());
    assertEquals("SOAP Header Test : - HeaderBlock1 namespace uri mismatch", "http://www.example.org", headerBlock1.getNamespace().getNamespaceURI());
    assertSame(headerBlock2, iterator.next());
    assertSame(soapHeader, headerBlock2.getParent());
    assertNotNull("SOAP Header Test : - After calling addHeaderBlock method twice, getChildren method returns an iterator with only one object", headerBlock2);
    assertEquals("SOAP Header Test : - HeaderBlock2 local name mismatch", "echoOk2", headerBlock2.getLocalName());
    assertEquals("SOAP Header Test : - HeaderBlock2 namespace uri mismatch", "http://www.example.org", headerBlock2.getNamespace().getNamespaceURI());
    assertFalse("SOAP Header Test : - After calling addHeaderBlock method twice, getChildren method returns an iterator with more than two elements", iterator.hasNext());
}
Also used : OMNode(org.apache.axiom.om.OMNode) OMNamespace(org.apache.axiom.om.OMNamespace) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 19 with SOAPEnvelope

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

the class TestAddHeaderBlockFromQName method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope env = soapFactory.getDefaultEnvelope();
    SOAPHeader header = env.getOrCreateHeader();
    SOAPHeaderBlock headerBlock = header.addHeaderBlock(new QName("urn:test", "test", "p"));
    assertSame(headerBlock, header.getFirstOMChild());
    assertEquals("test", headerBlock.getLocalName());
    assertEquals("p", headerBlock.getPrefix());
    assertEquals("urn:test", headerBlock.getNamespaceURI());
}
Also used : QName(javax.xml.namespace.QName) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 20 with SOAPEnvelope

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

the class TestAddHeaderBlockFromQNameWithoutNamespace method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPHeader header = soapFactory.createSOAPHeader(envelope);
    try {
        header.addHeaderBlock(new QName("test"));
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : QName(javax.xml.namespace.QName) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) OMException(org.apache.axiom.om.OMException) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Aggregations

SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)86 OMElement (org.apache.axiom.om.OMElement)28 SOAPBody (org.apache.axiom.soap.SOAPBody)23 OMNamespace (org.apache.axiom.om.OMNamespace)20 SOAPHeader (org.apache.axiom.soap.SOAPHeader)20 SOAPFault (org.apache.axiom.soap.SOAPFault)14 QName (javax.xml.namespace.QName)12 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)12 OMNode (org.apache.axiom.om.OMNode)11 SOAPModelBuilder (org.apache.axiom.soap.SOAPModelBuilder)11 SOAPFactory (org.apache.axiom.soap.SOAPFactory)10 SOAPFaultCode (org.apache.axiom.soap.SOAPFaultCode)8 StringReader (java.io.StringReader)7 OMSourcedElement (org.apache.axiom.om.OMSourcedElement)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 DataHandler (javax.activation.DataHandler)6 OMOutputFormat (org.apache.axiom.om.OMOutputFormat)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 MultipartBody (org.apache.axiom.mime.MultipartBody)5 SOAPFaultDetail (org.apache.axiom.soap.SOAPFaultDetail)5