SagHTTPGateway and servlets

To get around the problem of Natural Security, I wrote a servlet that logs on to Natural. Now I am running into a problem of trying to run a Mediator sequence that accesses the servlet. The sequence calls the servlet fine, but when the servlet returns data, Mediator throws an exception stating Response Message: Invalid Content Type: “text/html”. What’s strange is that within the servlet, I set my response type to “text/xml”. Also within my servlet, I am taking the XML document passed from Mediator and using it as input into my XMLAdapter and then trying to return the response to Mediator. It will only work if I take out the section of code dealing with reading in the XML document from Mediator. When I do this, and hardcode the XML into the invokeXML() method the document response returns fine. Does anybody know what the problem may be? Below is my servlet code:

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

BufferedReader in = null;
int contentLength = request.getContentLength();
char msgInput = new char[contentLength];
String result= “”;

if (contentLength >0){
// Trying to open buffer twice as big as original file
in = new BufferedReader(request.getReader(),contentLength*2);

}catch(Exception e){

Ffan161XmlAdapter adapter = new Ffan161XmlAdapter();
Broker broker = new Broker(adapter.getAdapterInfo().getBrokerID(),“B@AH”);

try {

XMLRPCService service = new XMLRPCService(broker, “RPC/SRV2/CALLNAT”,adapter);
Conversation conv = new Conversation(service);

String xmlDoc= new String(msgInput);
result = service.invokeXML(“200203000000001”);

} catch (Exception e) {
System.out.println(e + “\n”);

PrintWriter out = response.getWriter();
//out.println(“<?xml version=\"1.0\"?>”);

If you set the runtime Log Level to Debug in Mediator (using the Admin Console) you should see the incoming xml payload and the outgoing xml result in the file “…Program Files/Software AG/…Mediator…/host/logs/DefaultComponentFactory.xbd.log”.

Does the information in there help at all?