response.setStatusCode(HttpStatus.SC_MOVED_PERMANENTLY);
response.addHeader(LOCATION, servicePath + "/");
serverHandler.commitResponse(conn, response);
} else if (serviceName != null && parameters.containsKey("wsdl")) {
AxisService service = (AxisService) cfgCtx.getAxisConfiguration().
getServices().get(serviceName);
if (service != null) {
try {
response.addHeader(CONTENT_TYPE, TEXT_XML);
serverHandler.commitResponse(conn, response);
service.printWSDL(os, getIpAddress());
} catch (AxisFault e) {
handleException("Axis2 fault writing ?wsdl output", e);
return;
} catch (SocketException e) {
handleException("Error getting ip address for ?wsdl output", e);
return;
}
}
} else if (serviceName != null && parameters.containsKey("wsdl2")) {
AxisService service = (AxisService) cfgCtx.getAxisConfiguration().
getServices().get(serviceName);
if (service != null) {
try {
response.addHeader(CONTENT_TYPE, TEXT_XML);
serverHandler.commitResponse(conn, response);
service.printWSDL2(os, getIpAddress());
} catch (AxisFault e) {
handleException("Axis2 fault writing ?wsdl2 output", e);
return;
} catch (SocketException e) {
handleException("Error getting ip address for ?wsdl2 output", e);
return;
}
}
} else if (serviceName != null && parameters.containsKey("xsd")) {
if (parameters.get("xsd") == null || "".equals(parameters.get("xsd"))) {
AxisService service = (AxisService) cfgCtx.getAxisConfiguration()
.getServices().get(serviceName);
if (service != null) {
try {
response.addHeader(CONTENT_TYPE, TEXT_XML);
serverHandler.commitResponse(conn, response);
service.printSchema(os);
} catch (AxisFault axisFault) {
handleException("Error writing ?xsd output to client", axisFault);
return;
}
}
} else {
//cater for named xsds - check for the xsd name
String schemaName = (String) parameters.get("xsd");
AxisService service = (AxisService) cfgCtx.getAxisConfiguration()
.getServices().get(serviceName);
if (service != null) {
//run the population logic just to be sure
service.populateSchemaMappings();
//write out the correct schema
Map schemaTable = service.getSchemaMappingTable();
XmlSchema schema = (XmlSchema)schemaTable.get(schemaName);
if (schema == null) {
int dotIndex = schemaName.indexOf('.');
if (dotIndex > 0) {
String schemaKey = schemaName.substring(0,dotIndex);
schema = (XmlSchema) schemaTable.get(schemaKey);
}
}
//schema found - write it to the stream
if (schema != null) {
response.addHeader(CONTENT_TYPE, TEXT_XML);
serverHandler.commitResponse(conn, response);
schema.write(os);
} else {
// no schema available by that name - send 404
response.setStatusCode(HttpStatus.SC_NOT_FOUND);
}
}
}
} else if (serviceName == null || serviceName.length() == 0) {
try {
response.addHeader(CONTENT_TYPE, TEXT_HTML);
serverHandler.commitResponse(conn, response);
os.write(getServicesHTML().getBytes());
} catch (IOException e) {
handleException("Error writing ? output to client", e);
}
} else {
if (parameters.isEmpty()) {
AxisService service = (AxisService) cfgCtx.getAxisConfiguration().
getServices().get(serviceName);
if (service != null) {
try {
response.addHeader(CONTENT_TYPE, TEXT_HTML);
serverHandler.commitResponse(conn, response);