use of org.apache.axiom.soap.SOAPHeader in project webservices-axiom by apache.
the class TestRegisterCustomBuilder method runTest.
@Override
protected void runTest() throws Throwable {
SOAPModelBuilder builder = SOAPSampleSet.WSA.getMessage(spec).getAdapter(SOAPSampleAdapter.class).getBuilder(metaFactory);
((CustomBuilderSupport) builder).registerCustomBuilder(new CustomBuilder.Selector() {
@Override
public boolean accepts(OMContainer parent, int depth, String namespaceURI, String localName) {
return depth == 3 && namespaceURI.equals("http://www.w3.org/2005/08/addressing") && localName.equals("To");
}
}, new BlobOMDataSourceCustomBuilder(MemoryBlob.FACTORY, "utf-8"));
SOAPHeader header = builder.getSOAPEnvelope().getHeader();
ArrayList al = header.getHeaderBlocksWithNSURI("http://www.w3.org/2005/08/addressing");
assertEquals(al.size(), 4);
for (int i = 0; i < al.size(); i++) {
SOAPHeaderBlock shb = (SOAPHeaderBlock) al.get(i);
if ("To".equals(shb.getLocalName())) {
assertNotNull(shb.getDataSource());
}
}
}
use of org.apache.axiom.soap.SOAPHeader in project webservices-axiom by apache.
the class TestBodyHeaderOrder method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope env = soapFactory.createSOAPEnvelope();
soapFactory.createSOAPBody(env);
soapFactory.createSOAPHeader(env);
assertTrue("Header isn't the first child!", env.getFirstElement() instanceof SOAPHeader);
}
use of org.apache.axiom.soap.SOAPHeader in project webservices-axiom by apache.
the class TestGetHeaderWithParser method runTest.
@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
SOAPHeader header = envelope.getHeader();
assertEquals("Header Test : - Header local name mismatch", SOAPConstants.HEADER_LOCAL_NAME, header.getLocalName());
assertEquals("Header Test : - Header namespace mismatch", spec.getEnvelopeNamespaceURI(), header.getNamespace().getNamespaceURI());
}
use of org.apache.axiom.soap.SOAPHeader in project wso2-synapse by wso2.
the class LogMediator method getHeadersLogMessage.
private String getHeadersLogMessage(MessageContext synCtx) {
StringBuffer sb = new StringBuffer();
if (synCtx.getEnvelope() != null) {
SOAPHeader header = synCtx.getEnvelope().getHeader();
if (header != null) {
for (Iterator iter = header.examineAllHeaderBlocks(); iter.hasNext(); ) {
Object o = iter.next();
if (o instanceof SOAPHeaderBlock) {
SOAPHeaderBlock headerBlk = (SOAPHeaderBlock) o;
sb.append(separator).append(headerBlk.getLocalName()).append(" : ").append(headerBlk.getText());
} else if (o instanceof OMElement) {
OMElement headerElem = (OMElement) o;
sb.append(separator).append(headerElem.getLocalName()).append(" : ").append(headerElem.getText());
}
}
}
}
setCustomProperties(sb, synCtx);
return trimLeadingSeparator(sb);
}
use of org.apache.axiom.soap.SOAPHeader in project wso2-synapse by wso2.
the class HeaderMediator method addCustomHeader.
private void addCustomHeader(MessageContext synCtx, String value) {
SOAPEnvelope env = synCtx.getEnvelope();
if (env == null) {
return;
}
SOAPFactory fac = (SOAPFactory) env.getOMFactory();
SOAPHeader header = env.getHeader();
if (header == null) {
header = fac.createSOAPHeader(env);
}
if (!isImplicit()) {
SOAPHeaderBlock hb = header.addHeaderBlock(qName.getLocalPart(), fac.createOMNamespace(qName.getNamespaceURI(), qName.getPrefix()));
hb.setText(value);
} else if (hasEmbeddedXml()) {
addHeaderChildrenToMessageContext(synCtx, embeddedXmlContent);
} else {
// header mediator has an implicit xml element but its content cannot be found.
handleException("Header mediator has an implicit xml element but its content cannot be found.", synCtx);
}
}
Aggregations