Search in sources :

Example 41 with SOAPHeader

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

the class TestExamineAllHeaderBlocks 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");
    soapHeader.addHeaderBlock("echoOk1", namespace);
    soapHeader.addHeaderBlock("echoOk2", namespace);
    Iterator<SOAPHeaderBlock> iterator = soapHeader.examineAllHeaderBlocks();
    iterator.hasNext();
    SOAPHeaderBlock headerBlock1 = iterator.next();
    assertNotNull("SOAP Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks 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());
    assertTrue(iterator.hasNext());
    SOAPHeaderBlock headerBlock2 = iterator.next();
    assertNotNull("SOAP Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks 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, examineAllHeaderBlocks method returns an iterator with more than two object", iterator.hasNext());
}
Also used : 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 42 with SOAPHeader

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

the class TestExamineHeaderBlocks method runTest.

@Override
protected void runTest() throws Throwable {
    String roleNextURI = spec.getNextRoleURI();
    SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope();
    SOAPHeader soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
    OMNamespace namespace = soapFactory.createOMNamespace("http://www.example.org", "test");
    soapHeader.addHeaderBlock("echoOk1", namespace).setRole("urn:test-role");
    soapHeader.addHeaderBlock("echoOk2", namespace).setRole(roleNextURI);
    Iterator<SOAPHeaderBlock> iterator = soapHeader.examineHeaderBlocks(roleNextURI);
    iterator.hasNext();
    SOAPHeaderBlock headerBlockWithRole = iterator.next();
    assertEquals("SOAP Header Test : - headerBlockWithRole local name mismatch", "echoOk2", headerBlockWithRole.getLocalName());
    assertEquals("SOAP Header Test : - headerBlockWithRole role value mismatch", roleNextURI, headerBlockWithRole.getRole());
    assertFalse("SOAP Header Test : - header has one headerBlock with role, but examineHeaderBlocks(String role) method returns an iterator with more than one object", iterator.hasNext());
}
Also used : 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 43 with SOAPHeader

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

the class TestGetHeadersToProcessWithParser method runTest.

@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
    SOAPHeader soapHeader = envelope.getHeader();
    String[] roles = { "http://example.org/myCustomRole" };
    RolePlayer rp = new MyRolePlayer(true, roles);
    Iterator<SOAPHeaderBlock> headers = soapHeader.getHeadersToProcess(rp);
    assertTrue("No headers!", headers.hasNext());
    int numHeaders = 0;
    while (headers.hasNext()) {
        headers.next();
        numHeaders++;
    }
    assertEquals("Didn't get right number of headers (with custom role)", 6, numHeaders);
    rp = new MyRolePlayer(true);
    headers = soapHeader.getHeadersToProcess(rp);
    assertTrue(headers.hasNext());
    numHeaders = 0;
    while (headers.hasNext()) {
        headers.next();
        numHeaders++;
    }
    assertEquals("Didn't get right number of headers (no custom role)", 5, numHeaders);
    // Intermediary test
    rp = new MyRolePlayer(false);
    headers = soapHeader.getHeadersToProcess(rp);
    assertTrue(headers.hasNext());
    numHeaders = 0;
    while (headers.hasNext()) {
        headers.next();
        numHeaders++;
    }
    assertEquals("Didn't get right number of headers (no custom role)", 2, numHeaders);
}
Also used : SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) RolePlayer(org.apache.axiom.soap.RolePlayer) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 44 with SOAPHeader

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

the class TestClone method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPHeader header = soapFactory.createSOAPHeader();
    OMNamespace ns = soapFactory.createOMNamespace("urn:test", "p");
    SOAPHeaderBlock unprocessedHeaderBlock = header.addHeaderBlock("unprocessed", ns);
    SOAPHeaderBlock processedHeaderBlock = header.addHeaderBlock("processed", ns);
    processedHeaderBlock.setProcessed();
    SOAPCloneOptions options = new SOAPCloneOptions();
    options.setPreserveModel(true);
    options.setProcessedFlag(processed);
    SOAPHeader clonedHeader = (SOAPHeader) header.clone(options);
    checkProcessed(clonedHeader, unprocessedHeaderBlock);
    checkProcessed(clonedHeader, processedHeaderBlock);
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPHeader(org.apache.axiom.soap.SOAPHeader) SOAPCloneOptions(org.apache.axiom.soap.SOAPCloneOptions)

Example 45 with SOAPHeader

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

the class TestGetHeaderBlocksWithNSURI 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");
    soapHeader.addHeaderBlock("echoOk1", namespace);
    soapHeader.addHeaderBlock("echoOk2", soapFactory.createOMNamespace("http://www.test1.org", "test1"));
    ArrayList<SOAPHeaderBlock> arrayList = soapHeader.getHeaderBlocksWithNSURI("http://www.test1.org");
    assertEquals("SOAP Header Test : - getHeaderBlocksWithNSURI returns an arrayList of incorrect size", 1, arrayList.size());
    assertEquals("SOAP Header Test : - headerBlock of given namespace uri mismatch", "http://www.test1.org", arrayList.get(0).getNamespace().getNamespaceURI());
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Aggregations

SOAPHeader (org.apache.axiom.soap.SOAPHeader)56 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)33 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)32 OMElement (org.apache.axiom.om.OMElement)18 OMNamespace (org.apache.axiom.om.OMNamespace)15 QName (javax.xml.namespace.QName)13 Iterator (java.util.Iterator)10 OMNode (org.apache.axiom.om.OMNode)10 SOAPFactory (org.apache.axiom.soap.SOAPFactory)9 SOAPBody (org.apache.axiom.soap.SOAPBody)8 SOAPFault (org.apache.axiom.soap.SOAPFault)5 OMException (org.apache.axiom.om.OMException)4 EndpointReference (org.apache.axis2.addressing.EndpointReference)4 OMAttribute (org.apache.axiom.om.OMAttribute)3 SOAPFaultCode (org.apache.axiom.soap.SOAPFaultCode)3 SOAPFaultDetail (org.apache.axiom.soap.SOAPFaultDetail)3 SOAPFaultReason (org.apache.axiom.soap.SOAPFaultReason)3 BooleanAttributeAccessor (org.apache.axiom.ts.soap.BooleanAttributeAccessor)3 Element (org.w3c.dom.Element)3 StringReader (java.io.StringReader)2