String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 6);
HashMap services = configurationContext.getAxisConfiguration().getServices();
final AxisService service = (AxisService) services.get(serviceName);
if (service != null) {
final String ip = HttpUtils.getIpAddress();
EntityTemplate entity = new EntityTemplate(new ContentProducer() {
public void writeTo(final OutputStream outstream) throws IOException {
service.printWSDL2(outstream, ip, servicePath);
}
});
entity.setContentType("text/xml");
entity.setChunked(chunked);
response.setEntity(entity);
return;
}
}
if (uri.endsWith("?wsdl")) {
String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 5);
HashMap services = configurationContext.getAxisConfiguration().getServices();
final AxisService service = (AxisService) services.get(serviceName);
if (service != null) {
final String ip = HttpUtils.getIpAddress();
EntityTemplate entity = new EntityTemplate(new ContentProducer() {
public void writeTo(final OutputStream outstream) throws IOException {
service.printWSDL(outstream, ip, servicePath);
}
});
entity.setContentType("text/xml");
entity.setChunked(chunked);
response.setEntity(entity);
return;
}
}
if (uri.endsWith("?xsd")) {
String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 4);
HashMap services = configurationContext.getAxisConfiguration().getServices();
final AxisService service = (AxisService) services.get(serviceName);
if (service != null) {
EntityTemplate entity = new EntityTemplate(new ContentProducer() {
public void writeTo(final OutputStream outstream) throws IOException {
service.printSchema(outstream);
}
});
entity.setContentType("text/xml");
entity.setChunked(chunked);
response.setEntity(entity);
return;
}
}
//cater for named xsds - check for the xsd name
if (uri.indexOf("?xsd=") > 0) {
String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.lastIndexOf("?xsd="));
String schemaName = uri.substring(uri.lastIndexOf("=") + 1);
HashMap services = configurationContext.getAxisConfiguration().getServices();
AxisService service = (AxisService) services.get(serviceName);
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) {
EntityTemplate entity = new EntityTemplate(new ContentProducer() {
public void writeTo(final OutputStream outstream) {
schema.write(outstream);
}