All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.soitoolkit.commons.mule.soap.FixCxfEncodingInterceptor Maven / Gradle / Ivy

There is a newer version: 2.0.0-M6
Show newest version
package org.soitoolkit.commons.mule.soap;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.HttpHeaderHelper;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.interceptor.MessageSenderInterceptor;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.soitoolkit.commons.mule.jdbc.JdbcUtil;

/**
 * Based on a solution published in
 * http://www.mulesoft.org/jira/browse/MULE-4011 Is according to the jira fixed
 * in v3.0.1 and v3.1.0 so until then we will need this one!
 * 
 * Used by outbound-endpoints like:
 * 
 * 
 * 				
 * 					
 * 						
 * 					 
 * 				
 * 
* * @author magnuslarsson * */ public class FixCxfEncodingInterceptor extends AbstractPhaseInterceptor { private final static Logger log = LoggerFactory.getLogger(FixCxfEncodingInterceptor.class); public FixCxfEncodingInterceptor() { super(Phase.PREPARE_SEND); addBefore(MessageSenderInterceptor.class.getName()); } public void handleMessage(Message message) throws Fault { Map> headers = CastUtils.cast((Map) message.get(Message.PROTOCOL_HEADERS)); if (headers == null) { headers = new HashMap>(); message.put(Message.PROTOCOL_HEADERS, headers); } // String ct = (String) // message.getExchange().get(Endpoint.class).get(HttpHeaderHelper.CONTENT_TYPE); String ct = "text/xml;charset=UTF-8;"; if (ct != null) { List contentType = new ArrayList(); contentType.add(ct); headers.put(HttpHeaderHelper.getHeaderKey(HttpHeaderHelper.CONTENT_TYPE), contentType); message.put(HttpHeaderHelper.CONTENT_TYPE, ct); log.debug("### Added content-type: {}", ct); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy