camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Giger <gigerst...@gmx.ch>
Subject camel-cxf Soap-Fault not returned as 500 http error code
Date Tue, 10 Feb 2009 10:36:35 GMT
Hi,

I have (again) the problem that a soap-fault is not returned as 500 code.

This worked fine with camel-cxf 1.3 but not with camel-cxf 1.5. The reason
seems to be that the cxf response-context is not (correctly?) propagated back.

In 1.3 we had the following code to propagate the responseContext back to the caller:

CxfProducer line 252:

248: Object result = cxfClient.dispatch(params, context, ex);
249: ex.setOutMessage(response);
250: invokingContext.setResponseContent(response, result);
251: // copy the response context to the response
252: response.putAll(responseContext);
253: cxfBinding.storeCxfResponse(exchange, response);

This has changed in 1.5 to 

Object result = cxfClient.dispatch(params, context, ex);
ex.setOutMessage(response);
invokingContext.setResponseContent(response, result);
// copy the response context to the response
CxfBinding.storeCXfResponseContext(response, responseContext);
CxfBinding.storeCxfResponse(endpoint.getHeaderFilterStrategy(), exchange, response);

Which stores the responseContext itself as a new property in the message.

Later in the chain, AbstractHttpDestination searches a RESPONSE_CODE in the message:

Integer i = (Integer)outMessage.get(Message.RESPONSE_CODE);
            if (i != null) {
                int status = i.intValue();  
                if (HttpURLConnection.HTTP_INTERNAL_ERROR == i) {
                    Map<Object, Object> pHeaders = 
                        CastUtils.cast((Map)outMessage.get(Message.PROTOCOL_HEADERS));
                    if (null != pHeaders && pHeaders.containsKey(PROTOCOL_HEADERS_CONTENT_TYPE))
{
                        pHeaders.remove(PROTOCOL_HEADERS_CONTENT_TYPE);
                    }
                }
                response.setStatus(status);
            } else {
                response.setStatus(HttpURLConnection.HTTP_OK);
            }

which it doesn't find because the RESPONSE_CODE is stored in the ResponseContext which is
again a HashMap.
In this case the access to the RESPONSE_CODE would be:

((HashMap)outMessage.get("ResonseContext")).get(Message.RESPONSE_CODE)

which can't be the correct solution of course.

So, what do I have to do to get my 500 back?:-)

Thanks & Greets

Marc




Mime
View raw message