use of org.apache.axiom.soap.SOAPHeaderBlock in project webservices-axiom by apache.
the class TestExamineMustUnderstandHeaderBlocks method runTest.
@Override
protected void runTest() throws Throwable {
SOAPHeader header = soapFactory.createSOAPHeader();
// Add header blocks using DOM
Element domHeader = (Element) header;
Document document = domHeader.getOwnerDocument();
Element[] headerBlocks = new Element[3];
for (int i = 0; i < 3; i++) {
headerBlocks[i] = document.createElementNS("urn:test", "p:h" + i);
}
headerBlocks[1].setAttributeNS(spec.getEnvelopeNamespaceURI(), "S:mustUnderstand", "1");
for (int i = 0; i < 3; i++) {
// Clone the nodes because conversion to SOAPHeaderBlock is destructive
domHeader.appendChild(headerBlocks[i].cloneNode(true));
}
// Use the Axiom API to iterate over the header blocks
Iterator<SOAPHeaderBlock> it = header.examineMustUnderstandHeaderBlocks(null);
assertThat(it.hasNext()).isTrue();
SOAPHeaderBlock headerBlock = it.next();
assertAbout(xml()).that(xml(OMElement.class, headerBlock)).hasSameContentAs(xml(Element.class, headerBlocks[1]));
assertThat(it.hasNext()).isFalse();
}
use of org.apache.axiom.soap.SOAPHeaderBlock in project webservices-axiom by apache.
the class TestWrongParent3 method runTest.
@Override
protected void runTest() throws Throwable {
SOAPFaultDetail parent = soapFactory.createSOAPFaultDetail();
OMElement child1 = soapFactory.createOMElement("child1", null, parent);
SOAPHeaderBlock hb = soapFactory.createSOAPHeaderBlock("MyHeader", soapFactory.createOMNamespace("urn:test", "p"));
try {
child1.insertSiblingBefore(hb);
fail("Expected SOAPProcessingException");
} catch (SOAPProcessingException ex) {
// Expected
}
}
use of org.apache.axiom.soap.SOAPHeaderBlock in project webservices-axiom by apache.
the class TestExamineMustUnderstandHeaderBlocks 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).setRole("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
SOAPHeaderBlock headerBlock1 = soapHeader.addHeaderBlock("echoOk2", namespace);
headerBlock1.setRole("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
headerBlock1.setMustUnderstand(true);
soapHeader.addHeaderBlock("echoOk3", namespace).setMustUnderstand(true);
Iterator iterator = soapHeader.examineMustUnderstandHeaderBlocks("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
iterator.hasNext();
SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) iterator.next();
assertFalse("SOAP Header Test : - examineMustUnderstandHeaderBlocks method returns empty iterator", headerBlock == null);
assertTrue("SOAP Header Test : - HeaderBlock local name mismatch", headerBlock.getLocalName().equals("echoOk2"));
assertTrue("SOAP Header Test : - HeaderBlock role value mismatch", headerBlock.getRole().equals("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));
assertFalse("SOAP Header Test : - examineMustUnderstandHeaderBlocks method returns an iterator with more than one object", iterator.hasNext());
}
use of org.apache.axiom.soap.SOAPHeaderBlock in project webservices-axiom by apache.
the class TestCloneWithSourcedElement2 method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope sourceEnv = soapFactory.getDefaultEnvelope();
SOAPBody body = sourceEnv.getBody();
SOAPHeader header = sourceEnv.getHeader();
// Create a header OMSE
OMDataSource dsHdr = new StringOMDataSource("<hdr:myheader xmlns:hdr=\"urn://test\">Hello World</hdr:myheader>");
OMNamespace hdrNS = header.getOMFactory().createOMNamespace("urn://test", "hdr");
SOAPFactory sf = (SOAPFactory) header.getOMFactory();
SOAPHeaderBlock shb = sf.createSOAPHeaderBlock("myheader", hdrNS, dsHdr);
// test setting processing flag
shb.setProcessed();
header.addChild(shb);
// Create a payload
OMDataSource ds = new StringOMDataSource("<tns:payload xmlns:tns=\"urn://test\">Hello World</tns:payload>");
OMNamespace ns = body.getOMFactory().createOMNamespace("urn://test", "tns");
OMSourcedElement omse = body.getOMFactory().createOMElement(ds, "payload", ns);
body.addChild(omse);
copyAndCheck(sourceEnv);
// The source SOAPHeaderBlock should not be expanded in the process
assertFalse(shb.isExpanded());
}
use of org.apache.axiom.soap.SOAPHeaderBlock in project webservices-axiom by apache.
the class TestGetXMLStreamReaderWithoutCachingWithPartiallyBuiltHeaderBlock method runTest.
@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) envelope.getHeader().getFirstChildWithName(new QName("http://www.w3.org/2005/08/addressing", "ReplyTo"));
headerBlock.getFirstElement().getFirstOMChild();
assertFalse(headerBlock.isComplete());
XMLStreamReader reader = envelope.getXMLStreamReaderWithoutCaching();
while (reader.hasNext()) {
reader.next();
}
assertFalse(headerBlock.isComplete());
}
Aggregations