OutputStream out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
// I Don't think we need this check.. Content type needs to be set in
// any case. (thilina)
// if (msgContext.isServerSide()) {
OutTransportInfo transportInfo = (OutTransportInfo) msgContext
.getProperty(Constants.OUT_TRANSPORT_INFO);
if (transportInfo == null) throw new AxisFault("No transport info in MessageContext");
ServletBasedOutTransportInfo servletBasedOutTransportInfo = null;
if (transportInfo instanceof ServletBasedOutTransportInfo) {
servletBasedOutTransportInfo =
(ServletBasedOutTransportInfo) transportInfo;
// if sending a fault, set HTTP status code to 500
if (msgContext.isFault()) {
servletBasedOutTransportInfo.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
Object customHeaders = msgContext.getProperty(HTTPConstants.HTTP_HEADERS);
if (customHeaders != null) {
if (customHeaders instanceof List) {
Iterator iter = ((List) customHeaders).iterator();
while (iter.hasNext()) {
Header header = (Header) iter.next();
if (header != null) {
servletBasedOutTransportInfo
.addHeader(header.getName(), header.getValue());
}
}
} else if (customHeaders instanceof Map) {
Iterator iter = ((Map) customHeaders).entrySet().iterator();
while (iter.hasNext()) {
Map.Entry header = (Map.Entry) iter.next();
if (header != null) {
servletBasedOutTransportInfo
.addHeader((String) header.getKey(), (String) header.getValue());
}
}
}
}
} else if (transportInfo instanceof AxisHttpResponseImpl) {
Object customHeaders = msgContext.getProperty(HTTPConstants.HTTP_HEADERS);
if (customHeaders != null) {
if (customHeaders instanceof List) {
Iterator iter = ((List) customHeaders).iterator();
while (iter.hasNext()) {
Header header = (Header) iter.next();
if (header != null) {
((AxisHttpResponseImpl) transportInfo)
.addHeader(header.getName(), header.getValue());
}
}
} else if (customHeaders instanceof Map) {
Iterator iter = ((Map) customHeaders).entrySet().iterator();
while (iter.hasNext()) {
Map.Entry header = (Map.Entry) iter.next();
if (header != null) {
((AxisHttpResponseImpl) transportInfo)
.addHeader((String) header.getKey(), (String) header.getValue());
}
}
}
}
}
format.setAutoCloseWriter(true);
MessageFormatter messageFormatter = TransportUtils.getMessageFormatter(msgContext);
if (messageFormatter == null) throw new AxisFault("No MessageFormatter in MessageContext");
// Once we get to this point, exceptions should NOT be turned into faults and sent,
// because we're already sending! So catch everything and log it, but don't pass
// upwards.
try {
transportInfo.setContentType(
messageFormatter.getContentType(msgContext, format, findSOAPAction(msgContext)));
Object gzip = msgContext.getOptions().getProperty(HTTPConstants.MC_GZIP_RESPONSE);
if (gzip != null && JavaUtils.isTrueExplicitly(gzip)) {
if (servletBasedOutTransportInfo != null)