* @exception ServletException on message content or operational error
* @exception IOException on error reading or writing
*/
public void doPost(HttpServletRequest req, HttpServletResponse rsp) throws ServletException, IOException {
logger.debug("Entered WsServletDelegate.doPost()");
Service serv = null;
XmlCodec incodec = null;
XmlCodec outcodec = null;
InByteBuffer inbuff = null;
OutByteBuffer outbuff = null;
try {
// make sure we have a service instance
serv = m_serviceMapper.getServiceInstance(req);
if (serv == null) {
rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
} else {
MediaType intype = getMediaType(req.getContentType(), serv.getMediaTypeMapper());
MediaType outtype = getAcceptableMediaType(req.getHeader("Accept"), intype);
synchronized (s_codecPool) {
// allocated codec(s) and buffers for the input and output
incodec = s_codecPool.getCodec(intype);
if (intype.equals(outtype)) {
outcodec = incodec;
} else {
outcodec = s_codecPool.getCodec(outtype);
}
inbuff = (InByteBuffer) s_inBufferCache.getInstance();
outbuff = (OutByteBuffer) s_outBufferCache.getInstance();
}
// pass the processing on to the service
InboundConnection inconn = new InboundConnection(req, incodec, inbuff);
OutboundConnection outconn = new OutboundConnection(rsp, req.getCharacterEncoding(),
serv.getXmlOptions(), outcodec, outbuff);
HttpServletOptions options = (HttpServletOptions) serv.getTransportOptions(HttpServletOptions.class);
if (options != null) {
if (options.getInputStreamInterceptor() != null) {
inconn.setInterceptor(options.getInputStreamInterceptor());
}
if (options.getOutputStreamInterceptor() != null) {
outconn.setInterceptor(options.getOutputStreamInterceptor());
}
}
serv.processRequest(inconn, outconn);
}
} catch (WsException e) {
logger.error("Error processing request", e);
rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
} finally {
synchronized (s_codecPool) {
// release all resources acquired for processing request
if (serv != null) {
serv.releaseInstance();
}
if (incodec != null) {
s_codecPool.releaseCodec(incodec);
}
if (outcodec != null && outcodec != incodec) {