Search in sources :

Example 1 with SOAPHeader

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

the class TestExtractAllHeaderBlocks method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPHeader header = soapFactory.createSOAPHeader(envelope);
    OMNamespace ns = soapFactory.createOMNamespace("urn:ns", "p");
    SOAPHeaderBlock h1 = header.addHeaderBlock("header1", ns);
    SOAPHeaderBlock h2 = header.addHeaderBlock("header2", ns);
    Iterator<SOAPHeaderBlock> it = header.extractAllHeaderBlocks();
    assertTrue(it.hasNext());
    assertSame(h1, it.next());
    assertTrue(it.hasNext());
    assertSame(h2, it.next());
    assertFalse(it.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 2 with SOAPHeader

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

the class TestGetHeadersToProcessWithNamespace method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPHeader header = soapFactory.createSOAPHeader(envelope);
    OMNamespace ns1 = soapFactory.createOMNamespace("urn:ns1", "ns1");
    OMNamespace ns2 = soapFactory.createOMNamespace("urn:ns2", "ns2");
    String myRole = "urn:myRole";
    String otherRole = "urn:otherRole";
    SOAPHeaderBlock headerBlock1 = header.addHeaderBlock("header1", ns1);
    headerBlock1.setRole(myRole);
    SOAPHeaderBlock headerBlock2 = header.addHeaderBlock("header2", ns2);
    headerBlock2.setRole(myRole);
    SOAPHeaderBlock headerBlock3 = header.addHeaderBlock("header3", ns1);
    headerBlock3.setRole(myRole);
    SOAPHeaderBlock headerBlock4 = header.addHeaderBlock("header4", ns1);
    headerBlock4.setRole(otherRole);
    Iterator<SOAPHeaderBlock> it = header.getHeadersToProcess(new MyRolePlayer(false, new String[] { myRole }), ns1.getNamespaceURI());
    assertTrue(it.hasNext());
    assertSame(headerBlock1, it.next());
    assertTrue(it.hasNext());
    assertSame(headerBlock3, it.next());
    assertFalse(it.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 3 with SOAPHeader

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

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

the class TestGetBooleanAttributeDefault method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPHeader header = soapFactory.getDefaultEnvelope().getOrCreateHeader();
    SOAPHeaderBlock headerBlock = header.addHeaderBlock(new QName("http://example.org", "test", "h"));
    assertFalse(attribute.getAdapter(BooleanAttributeAccessor.class).getValue(headerBlock));
}
Also used : QName(javax.xml.namespace.QName) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 5 with SOAPHeader

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

the class TestGetBooleanAttribute method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPHeader header = soapFactory.getDefaultEnvelope().getOrCreateHeader();
    SOAPHeaderBlock headerBlock = header.addHeaderBlock(new QName("http://example.org", "test", "h"));
    headerBlock.addAttribute(attribute.getName(spec), literal.getLexicalRepresentation(), header.getNamespace());
    assertEquals(literal.getValue(), attribute.getAdapter(BooleanAttributeAccessor.class).getValue(headerBlock));
}
Also used : QName(javax.xml.namespace.QName) 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