use of org.apache.cxf.headers.Header in project cxf by apache.
the class MAPCodecTest method setUpHeaderDecode.
private <T> void setUpHeaderDecode(List<Header> headers, String uri, String name, Class<?> clz, int index, Unmarshaller unmarshaller) throws Exception {
Element headerElement = control.createMock(Element.class);
headers.add(new Header(new QName(uri, name), headerElement));
headerElement.getNamespaceURI();
EasyMock.expectLastCall().andReturn(uri);
headerElement.getLocalName();
EasyMock.expectLastCall().andReturn(name);
Object v = expectedValues[index];
@SuppressWarnings("unchecked") JAXBElement<?> jaxbElement = new JAXBElement<Object>(new QName(uri, name), (Class<Object>) clz, clz.cast(v));
unmarshaller.unmarshal(headerElement, clz);
EasyMock.expectLastCall().andReturn(jaxbElement);
}
use of org.apache.cxf.headers.Header in project cxf by apache.
the class HeaderVerifier method addPartialResponseHeader.
private void addPartialResponseHeader(SoapMessage message) {
try {
// add piggybacked wsa:From header to partial response
List<Header> header = message.getHeaders();
Document doc = DOMUtils.getEmptyDocument();
SoapVersion ver = message.getVersion();
Element hdr = doc.createElementNS(ver.getHeader().getNamespaceURI(), ver.getHeader().getLocalPart());
hdr.setPrefix(ver.getHeader().getPrefix());
marshallFrom("urn:piggyback_responder", hdr, getMarshaller());
Element elem = DOMUtils.getFirstElement(hdr);
while (elem != null) {
Header holder = new Header(new QName(elem.getNamespaceURI(), elem.getLocalName()), elem, null);
header.add(holder);
elem = DOMUtils.getNextElement(elem);
}
} catch (Exception e) {
verificationCache.put("SOAP header addition failed: " + e);
e.printStackTrace();
}
}
use of org.apache.cxf.headers.Header in project tesb-rt-se by Talend.
the class FlowIdSoapCodec method readFlowId.
/**
* Read flow id.
*
* @param message the message
* @return flow id from the message
*/
public static String readFlowId(Message message) {
if (!(message instanceof SoapMessage)) {
return null;
}
String flowId = null;
Header hdFlowId = ((SoapMessage) message).getHeader(FLOW_ID_QNAME);
if (hdFlowId != null) {
if (hdFlowId.getObject() instanceof String) {
flowId = (String) hdFlowId.getObject();
} else if (hdFlowId.getObject() instanceof Node) {
Node headerNode = (Node) hdFlowId.getObject();
flowId = headerNode.getTextContent();
} else {
LOG.warning("Found FlowId soap header but value is not a String or a Node! Value: " + hdFlowId.getObject().toString());
}
}
return flowId;
}
use of org.apache.cxf.headers.Header in project tesb-rt-se by Talend.
the class FlowIdSoapCodec method writeFlowId.
/**
* Write flow id to message.
*
* @param message the message
* @param flowId the flow id
*/
public static void writeFlowId(Message message, String flowId) {
if (!(message instanceof SoapMessage)) {
return;
}
SoapMessage soapMessage = (SoapMessage) message;
Header hdFlowId = soapMessage.getHeader(FLOW_ID_QNAME);
if (hdFlowId != null) {
LOG.warning("FlowId already existing in soap header, need not to write FlowId header.");
return;
}
try {
soapMessage.getHeaders().add(new Header(FLOW_ID_QNAME, flowId, new JAXBDataBinding(String.class)));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Stored flowId '" + flowId + "' in soap header: " + FLOW_ID_QNAME);
}
} catch (JAXBException e) {
LOG.log(Level.SEVERE, "Couldn't create flowId header.", e);
}
}
use of org.apache.cxf.headers.Header in project tesb-rt-se by Talend.
the class RuntimeESBEndpointRegistry method listSoapHeaders.
@SuppressWarnings("unchecked")
private List<Header> listSoapHeaders(Object soapHeadersObject) throws TransformerFactoryConfigurationError {
if (null != soapHeadersObject) {
if (soapHeadersObject instanceof org.dom4j.Document) {
List<Header> soapHeaders = new ArrayList<Header>();
try {
DOMResult result = new DOMResult();
TransformerFactory.newInstance().newTransformer().transform(new org.dom4j.io.DocumentSource((org.dom4j.Document) soapHeadersObject), result);
for (Node node = ((Document) result.getNode()).getDocumentElement().getFirstChild(); node != null; node = node.getNextSibling()) {
if (Node.ELEMENT_NODE == node.getNodeType()) {
soapHeaders.add(new Header(new QName(node.getNamespaceURI(), node.getLocalName()), node));
}
}
} catch (Exception e) {
LOG.log(Level.SEVERE, "Uncaught exception during SOAP headers transformation: ", e);
}
} else if (soapHeadersObject instanceof List) {
return (List<Header>) soapHeadersObject;
}
}
return null;
}
Aggregations