Search in sources :

Example 11 with SOAPHeaderBlock

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

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

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

the class TestGetRole method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPHeaderBlock soapHeaderBlock = createSOAPHeaderBlock();
    assertNull("SOAP HeaderBlock Test : - After creating SOAPHeaderBlock, it has a role", soapHeaderBlock.getRole());
    soapHeaderBlock.setRole("http://example.org/my-role");
    assertEquals("SOAP HeaderBlock Test : - After calling setRole method, getRole method returns incorrect role value", "http://example.org/my-role", soapHeaderBlock.getRole());
}
Also used : SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock)

Example 14 with SOAPHeaderBlock

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

the class TestGetVersion method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPHeaderBlock h = soapFactory.createSOAPHeaderBlock("myHeader", soapFactory.createOMNamespace("urn:test", "p"));
    assertSame(spec.getAdapter(SOAPVersion.class), h.getVersion());
}
Also used : SOAPVersion(org.apache.axiom.soap.SOAPVersion) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock)

Example 15 with SOAPHeaderBlock

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

the class TestSetBooleanAttributeUnsupported method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPHeader header = soapFactory.getDefaultEnvelope().getOrCreateHeader();
    SOAPHeaderBlock headerBlock = header.addHeaderBlock(new QName("urn:test", "test", "p"));
    try {
        attribute.getAdapter(BooleanAttributeAccessor.class).setValue(headerBlock, true);
        fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException ex) {
    // Expected
    }
}
Also used : QName(javax.xml.namespace.QName) BooleanAttributeAccessor(org.apache.axiom.ts.soap.BooleanAttributeAccessor) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Aggregations

SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)40 SOAPHeader (org.apache.axiom.soap.SOAPHeader)22 QName (javax.xml.namespace.QName)15 OMNamespace (org.apache.axiom.om.OMNamespace)13 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)12 OMElement (org.apache.axiom.om.OMElement)8 OMAttribute (org.apache.axiom.om.OMAttribute)4 OMNode (org.apache.axiom.om.OMNode)4 SOAPBody (org.apache.axiom.soap.SOAPBody)4 SOAPProcessingException (org.apache.axiom.soap.SOAPProcessingException)4 BooleanAttributeAccessor (org.apache.axiom.ts.soap.BooleanAttributeAccessor)4 SOAPFault (org.apache.axiom.soap.SOAPFault)3 SOAPFaultDetail (org.apache.axiom.soap.SOAPFaultDetail)3 StringReader (java.io.StringReader)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 OMSourcedElement (org.apache.axiom.om.OMSourcedElement)2 OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)2 BlobOMDataSource (org.apache.axiom.om.ds.BlobOMDataSource)2 SOAPCloneOptions (org.apache.axiom.soap.SOAPCloneOptions)2 SOAPFaultCode (org.apache.axiom.soap.SOAPFaultCode)2