Index: XFireServletChannel.java =================================================================== --- XFireServletChannel.java (revision 1941) +++ XFireServletChannel.java (working copy) @@ -13,6 +13,7 @@ import org.codehaus.xfire.attachments.Attachments; import org.codehaus.xfire.attachments.JavaMailAttachments; import org.codehaus.xfire.attachments.SimpleAttachment; +import org.codehaus.xfire.exchange.AbstractMessage; import org.codehaus.xfire.exchange.OutMessage; import org.codehaus.xfire.soap.SoapConstants; import org.codehaus.xfire.transport.Channel; @@ -21,7 +22,7 @@ /** * @author Dan Diephouse */ -final class XFireServletChannel extends HttpChannel +public class XFireServletChannel extends HttpChannel { public XFireServletChannel(String uri, HttpTransport transport) @@ -77,7 +78,7 @@ } else { - response.setContentType(HttpChannel.getSoapMimeType(message, true)); + response.setContentType(doGetSoapMimeType(message, true)); out = new BufferedOutputStream(response.getOutputStream()); message.setProperty(Channel.OUTPUTSTREAM, out); @@ -91,4 +92,9 @@ throw new XFireException("Couldn't send message.", e); } } + + protected String doGetSoapMimeType(AbstractMessage msg, boolean includeEncoding) + { + return HttpChannel.getSoapMimeType(msg, includeEncoding); + } } Index: XFireServletController.java =================================================================== --- XFireServletController.java (revision 1941) +++ XFireServletController.java (working copy) @@ -49,7 +49,7 @@ protected XFire xfire; protected SoapHttpTransport transport; - private ServletContext servletContext; + protected ServletContext servletContext; public XFireServletController(XFire xfire) { @@ -194,22 +194,11 @@ } } - /** - * @param request - * @param response - * @param service - * @throws ServletException - * @throws IOException - * @throws UnsupportedEncodingException - */ - protected void invoke(HttpServletRequest request, + protected MessageContext createMessageContext( + HttpServletRequest request, HttpServletResponse response, String service) - throws ServletException, IOException, UnsupportedEncodingException { - response.setStatus(200); - response.setBufferSize(1024 * 8); - XFireHttpSession session = new XFireHttpSession(request); MessageContext context = new MessageContext(); context.setXFire(getXFire()); @@ -220,17 +209,42 @@ if (servletContext != null) context.setProperty(HTTP_SERVLET_CONTEXT, servletContext); - - Channel channel; + + return context; + } + + protected Channel createChannel(MessageContext context) throws ServletException + { + HttpServletRequest request = (HttpServletRequest) context.getProperty(HTTP_SERVLET_REQUEST); try { - channel = transport.createChannel(request.getRequestURI()); + return transport.createChannel(request.getRequestURI()); } catch (Exception e) { logger.debug("Couldn't open channel.", e); throw new ServletException("Couldn't open channel.", e); } + } + + /** + * @param request + * @param response + * @param service + * @throws ServletException + * @throws IOException + * @throws UnsupportedEncodingException + */ + protected void invoke(HttpServletRequest request, + HttpServletResponse response, + String service) + throws ServletException, IOException, UnsupportedEncodingException + { + response.setStatus(200); + response.setBufferSize(1024 * 8); + + MessageContext context = createMessageContext(request, response, service); + Channel channel = createChannel(context); String soapAction = getSoapAction(request); String contentType = request.getContentType(); @@ -297,7 +311,7 @@ } } - private String dequote(String charEncoding) + protected String dequote(String charEncoding) { if(charEncoding != null && charEncoding.length()> 0 ){ if( ( charEncoding.charAt(0)=='"' && charEncoding.charAt(charEncoding.length()-1) == '"') @@ -308,7 +322,7 @@ return charEncoding; } - private String getSoapAction(HttpServletRequest request) + protected String getSoapAction(HttpServletRequest request) { String action = request.getHeader(SoapConstants.SOAP_ACTION); @@ -320,7 +334,7 @@ return action; } - private String getEncoding(String enc) throws ServletException + protected String getEncoding(String enc) throws ServletException { if (enc == null) return "UTF-8";