from(getRouterEndpointURI()).process(new Processor() {
@SuppressWarnings("unchecked")
public void process(Exchange exchange) throws Exception {
CxfPayload<SoapHeader> payload = exchange.getIn().getBody(CxfPayload.class);
List<Source> elements = payload.getBodySources();
assertNotNull(elements, "We should get the elements here");
assertEquals(1, elements.size(), "Get the wrong elements size");
Element el = new XmlConverter().toDOMElement(elements.get(0));
elements.set(0, new DOMSource(el));
assertEquals("http://camel.apache.org/pizza/types",
el.getNamespaceURI(), "Get the wrong namespace URI");
List<SoapHeader> headers = payload.getHeaders();
assertNotNull(headers, "We should get the headers here");
assertEquals(1, headers.size(), "Get the wrong headers size");
assertEquals("http://camel.apache.org/pizza/types",
((Element) (headers.get(0).getObject())).getNamespaceURI(), "Get the wrong namespace URI");
// alternatively you can also get the SOAP header via the camel header:
headers = exchange.getIn().getHeader(Header.HEADER_LIST, List.class);
assertNotNull(headers, "We should get the headers here");
assertEquals(1, headers.size(), "Get the wrong headers size");
assertEquals("http://camel.apache.org/pizza/types",
((Element) (headers.get(0).getObject())).getNamespaceURI(), "Get the wrong namespace URI");
}
})
.to(getServiceEndpointURI());
from(getRouterEndpointURI()).process(new Processor() {
@SuppressWarnings("unchecked")
public void process(Exchange exchange) throws Exception {
CxfPayload<SoapHeader> payload = exchange.getIn().getBody(CxfPayload.class);
List<Source> elements = payload.getBodySources();
assertNotNull(elements, "We should get the elements here");
assertEquals(1, elements.size(), "Get the wrong elements size");
Element el = new XmlConverter().toDOMElement(elements.get(0));
elements.set(0, new DOMSource(el));
assertEquals("http://camel.apache.org/pizza/types",
el.getNamespaceURI(), "Get the wrong namespace URI");
List<SoapHeader> headers = payload.getHeaders();
assertNotNull(headers, "We should get the headers here");
assertEquals(1, headers.size(), "Get the wrong headers size");
assertEquals("http://camel.apache.org/pizza/types",
((Element) (headers.get(0).getObject())).getNamespaceURI(), "Get the wrong namespace URI");
// alternatively you can also get the SOAP header via the camel header:
headers = exchange.getIn().getHeader(Header.HEADER_LIST, List.class);
assertNotNull(headers, "We should get the headers here");
assertEquals(1, headers.size(), "Get the wrong headers size");
assertEquals("http://camel.apache.org/pizza/types",
((Element) (headers.get(0).getObject())).getNamespaceURI(), "Get the wrong namespace URI");
}
})
.to(getServiceEndpointURI());
Copy to ClipboardCopied!Toggle word wrapToggle overflow