if (wsdlReq == null) {
wsdlReq = request.getParameter("WSDL");
}
if (wsdlReq != null) {
String serviceName = RequestHandler.getOverrideViewUri(request.getPathInfo());
DispatchContext dctx = dispatcher.getDispatchContext();
String locationUri = this.getLocationURI(request);
if (serviceName != null) {
Document wsdl = null;
try {
wsdl = dctx.getWSDL(serviceName, locationUri);
} catch (GenericServiceException e) {
serviceName = null;
} catch (WSDLException e) {
sendError(response, "Unable to obtain WSDL");
throw new EventHandlerException("Unable to obtain WSDL", e);
}
if (wsdl != null) {
try {
OutputStream os = response.getOutputStream();
response.setContentType("text/xml");
UtilXml.writeXmlDocument(os, wsdl);
response.flushBuffer();
} catch (IOException e) {
throw new EventHandlerException(e);
}
return null;
} else {
sendError(response, "Unable to obtain WSDL");
throw new EventHandlerException("Unable to obtain WSDL");
}
}
if (serviceName == null) {
try {
Writer writer = response.getWriter();
StringBuilder sb = new StringBuilder();
sb.append("<html><head><title>OFBiz SOAP/1.1 Services</title></head>");
sb.append("<body>No such service.").append("<p>Services:<ul>");
for (String scvName: dctx.getAllServiceNames()) {
ModelService model = dctx.getModelService(scvName);
if (model.export) {
sb.append("<li><a href=\"").append(locationUri).append("/").append(model.name).append("?wsdl\">");
sb.append(model.name).append("</a></li>");
}
}