Hi Sergey,
> Can you also do System.out.println(response.getEntity().toString())
in your mapper, before returning ?
2009-02-17 06:25:53,024 | INFO [l0-0][ SolegyFaultMapper]
entity: The server encountered some error. Involved personnel have been
notified of this incident. Please contact support for follow-up. Issue
#2009480001
TCPMon captured:
HTTP/1.1 500 Internal Server Error
Content-Type: text/plain
Authentication-Info:
nextnonce="MTIzNDg1MTk1MzAzOTphYjk1ZDllOTkzMDEyNWRlZThkY2ExOWExZThjNjYwNQ=="
Content-Type: text/plain
Content-Length: 163
Server: Jetty(6.1.11)
<Result>The server encountered some error. Involved personnel have been
notified of this incident. Please contact support for follow-up. Issue
#2009480001</Result>
> Can you please confirm your own code (interceptors, etc) does not
wrap the message text ?
There is only one out interceptor, and it only adds the nextnonce as
seen in the capture above. Code is as follows:
public void handleMessage(Message message) throws Fault {
String base_path = (String)message.get(Message.BASE_PATH);
logger.debug("Adding nextnonce...");
addNextNonce(message, base_path);
/*-
* The next few steps should not be necessary. However, CXF
support team
* is still unable to explain why the added header is
ignored/overwritten/removed
*
* see:
http://www.nabble.com/-OutInterceptor--HttpHeader--Adding-Authorization-Info-entry-to-http-header-td20375003.html
*/
message.getInterceptorChain().abort();
try {
RestHandlerUtility.getConduit(message).prepare(message);
RestHandlerUtility.close(message);
} catch (IOException e) {
logger.warn(e.getMessage(), e);
}
}
/**
* Note that all values should be quoted as per <a
HREF="http://www.ietf.org/rfc/rfc2617">RFC</a>.
*
* @param message
* @param base_path
*/
private void addNextNonce(Message message, String base_path) {
// Set the response headers
@SuppressWarnings("unchecked")
Map<String, List<String>> responseHeaders = (Map<String,
List<String>>)message.get(Message.PROTOCOL_HEADERS);
if (responseHeaders == null) {
responseHeaders = new HashMap<String, List<String>>();
message.put(Message.PROTOCOL_HEADERS, responseHeaders);
}
responseHeaders.put("Authentication-Info", Arrays.asList(new
String[]{"nextnonce=\""+RestHandlerUtility.generateNonce(base_path)+"\""}));
logger.debug("out message headers: " + responseHeaders);
}
where RestHandlerUtility methods are:
/**
* Taken from <a
HREF="http://chrisdail.com/2008/03/31/apache-cxf-with-http-basic-authentication/">a
blog of Chris Dail</a>
*/
static Conduit getConduit(Message inMessage) throws IOException {
Exchange exchange = inMessage.getExchange();
EndpointReferenceType target =
exchange.get(EndpointReferenceType.class);
Conduit conduit =
exchange.getDestination().getBackChannel(inMessage, null, target);
exchange.setConduit(conduit);
return conduit;
}
/**
* Taken from <a
HREF="http://chrisdail.com/2008/03/31/apache-cxf-with-http-basic-authentication/">a
blog of Chris Dail</a>
*/
static void close(Message outMessage) throws IOException {
OutputStream os = outMessage.getContent(OutputStream.class);
try{
os.flush();
} catch (Exception e){
logger.warn("Unable to flush data. " + e.getMessage(), e);
}
try{
os.close();
} catch (Exception e){
logger.warn("Unable to close stream. " + e.getMessage(), e);
}
}
I had to use this to force the header entry to be included in the
output. Not aborting the chain results in the header not being included.
> I'm bewildered :-) I've no idea where this <Result> is coming
from...I've searched the CXF code base for expressions
> containing 'Result' and found no obvious culprit...
I'm thinking maybe it is translated as a regular bean and that the said
class is annotated as such? I tried debugging the OutputStream
os = outMessage.getContent(OutputStream.class); step by step to no avail.
Gabo