Search in sources :

Example 6 with SOAPHeader

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

the class TestGetBooleanAttributeInvalid method runTest.

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

Example 7 with SOAPHeader

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

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

use of org.apache.axiom.soap.SOAPHeader 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)

Example 10 with SOAPHeader

use of org.apache.axiom.soap.SOAPHeader 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

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