}
}
//--- extract basic info
HttpServiceRequest srvReq = new HttpServiceRequest(res);
srvReq.setDebug (extractDebug(url));
srvReq.setLanguage (extractLanguage(url));
srvReq.setService (extractService(url));
srvReq.setJSONOutput (extractJSONFlag(req.getQueryString()));
String ip = req.getRemoteAddr();
String forwardedFor = req.getHeader("x-forwarded-for");
if (forwardedFor != null) ip = forwardedFor;
srvReq.setAddress (ip);
srvReq.setOutputStream(res.getOutputStream());
//--- discover the input/output methods
String accept = req.getHeader("Accept");
if (accept != null)
{
int soapNDX = accept.indexOf("application/soap+xml");
int xmlNDX = accept.indexOf("application/xml");
int htmlNDX = accept.indexOf("html");
if (soapNDX != -1)
srvReq.setOutputMethod(OutputMethod.SOAP);
else if (xmlNDX != -1 && htmlNDX == -1)
srvReq.setOutputMethod(OutputMethod.XML);
}
if ("POST".equals(req.getMethod()))
{
srvReq.setInputMethod(InputMethod.POST);
String contType = req.getContentType();
if (contType != null)
{
if (contType.indexOf("application/soap+xml") != -1)
{
srvReq.setInputMethod (InputMethod.SOAP);
srvReq.setOutputMethod(OutputMethod.SOAP);
}
else if (contType.indexOf("application/xml") != -1 || contType.indexOf("text/xml") != -1)
srvReq.setInputMethod(InputMethod.XML);
}
}
//--- retrieve input parameters
InputMethod input = srvReq.getInputMethod();
if ((input == InputMethod.XML) || (input == InputMethod.SOAP))
{
if (req.getMethod().equals("GET"))
srvReq.setParams(extractParameters(req, uploadDir, maxUploadSize));
else
srvReq.setParams(extractXmlParameters(req));
}
else
{
//--- GET or POST
srvReq.setParams(extractParameters(req, uploadDir, maxUploadSize));
}
srvReq.setHeaders(extractHeaders(req));
return srvReq;
}