URI uri = request.getURI();
String path = uri.getPath();
String soapAction = request.getHeader(HTTPConstants.HEADER_SOAP_ACTION);
HashMap services = configurationContext.getAxisConfiguration().getServices();
AxisService service = null;
String serviceName = null;
if(services.size() == 1){
service = (AxisService)(services.values().iterator().next());
serviceName = (String)(services.keySet().iterator().next());
}else { // can't be happen
log.error("Invalid service configurations ");
throw new RuntimeException("Invalid Configuration");
}
// TODO: Port this section
// // Adjust version and content chunking based on the config
// boolean chunked = false;
// TransportOutDescription transportOut = msgContext.getTransportOut();
// if (transportOut != null) {
// Parameter p = transportOut.getParameter(HTTPConstants.PROTOCOL_VERSION);
// if (p != null) {
// if (HTTPConstants.HEADER_PROTOCOL_10.equals(p.getValue())) {
// ver = HttpVersion.HTTP_1_0;
// }
// }
// if (ver.greaterEquals(HttpVersion.HTTP_1_1)) {
// p = transportOut.getParameter(HTTPConstants.HEADER_TRANSFER_ENCODING);
// if (p != null) {
// if (HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED.equals(p.getValue())) {
// chunked = true;
// }
// }
// }
// }
if (request.getMethod() == Request.GET) {
if (!path.startsWith(contextPath)) {
response.setStatusCode(301);
response.setHeader("Location", contextPath);
return;
}
if (uri.toString().indexOf("?") < 0) {
if (!path.endsWith(contextPath)) {
if (serviceName.indexOf("/") < 0) {
String res = HTTPTransportReceiver.printServiceHTML(serviceName, configurationContext);
PrintWriter pw = new PrintWriter(response.getOutputStream());
pw.write(res);
pw.flush();
return;
}
}
}
if (uri.getQuery().startsWith("wsdl2")) {
if (service != null) {
service.printWSDL2(response.getOutputStream(), uri.getHost(), servicePath);
return;
}
}
if (uri.getQuery().startsWith("wsdl")) {
if(service != null){
service.printWSDL(response.getOutputStream(), uri.getHost(), servicePath);
return;
}
}
if (uri.getQuery().startsWith("xsd=")) {
if (service != null) {
service.printSchema(response.getOutputStream());
return;
}
}
//cater for named xsds - check for the xsd name
if (uri.getQuery().startsWith("xsd")) {
String schemaName = uri.getQuery().substring(uri.getQuery().lastIndexOf("=") + 1);
if (service != null) {
//run the population logic just to be sure
service.populateSchemaMappings();
//write out the correct schema
Map schemaTable = service.getSchemaMappingTable();
final XmlSchema schema = (XmlSchema) schemaTable.get(schemaName);
//schema found - write it to the stream
if (schema != null) {
schema.write(response.getOutputStream());
return;