Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Interceptor to modify the endpoint address based on the originalUrl header.
- * Used to support IPF endpoints containing pre-existing parameters in their URL.
- */
- @Slf4j
- public class IpfEndpointWithParamsInterceptor extends AbstractPhaseInterceptor<Message> {
- public IpfEndpointWithParamsInterceptor() {
- super(Phase.PRE_LOGICAL);
- }
- @Override
- public void handleMessage(Message message) throws Fault {
- String address = (String) message.get(Message.ENDPOINT_ADDRESS);
- Object headers = message.get("org.apache.cxf.headers.Header.list");
- if (headers instanceof List<?> headerList && address != null) {
- for (int i = 0; i < headerList.size(); i++) {
- Object obj = headerList.get(i);
- if (obj instanceof SoapHeader header && header.getName().getLocalPart().equals("originalUrl")
- && header.getName().getNamespaceURI().equals("http://example.com/schema")) {
- Object headerObj = header.getObject();
- if (headerObj != null) {
- String originalUrl = headerObj.toString();
- LOGGER.debug("Found originalUrl: {}", originalUrl);
- LOGGER.debug("Endpoint address after Camel chewed on it: {}", address);
- message.put(Message.ENDPOINT_ADDRESS, originalUrl);
- headerList.remove(i);
- LOGGER.debug("Modified endpoint address to: {} and removed the soap header", originalUrl);
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment