我正在与Axis合作构建SOAP客户端。我想打印完整的http请求和响应。我设法创建了打印SOAP信封的处理程序。如何将其扩展为打印完整的http?
public class CustomMessageHandler extends GenericHandler {
HandlerInfo hi;
public void init(HandlerInfo info) {
hi = info;
System.out.println("CustomMessageHandler initialized");
}
public QName[] getHeaders() {
return hi.getHeaders();
}
public boolean handleRequest(MessageContext context) {
try {
SOAPMessageContext smc = (SOAPMessageContext) context;
SOAPMessage msg = smc.getMessage();
System.out.println("request:");
msg.writeTo(System.out);
System.out.println("");
} catch (Exception ex) {
ex.printStackTrace();
}
return true;
}
public boolean handleResponse(MessageContext context) {
try {
SOAPMessageContext smc = (SOAPMessageContext) context;
SOAPMessage msg = smc.getMessage();
System.out.println("response:");
msg.writeTo(System.out);
System.out.println("");
} catch (Exception ex) {
ex.printStackTrace();
}
return true;
}
}
答案 0 :(得分:0)
此阶段的请求和响应处理程序可能没有完整的请求和响应。可能是Axis Servlet会做它或HTTP处理程序。 尝试编写过滤器并记录完整的请求和响应吗?