metaclass = m_context.getMetadata().findMetaclass(sClassName);
if (metaclass == null)
{
throw new RequestException("err.rpc.xml.class", new Object[]{sClassName});
}
}
sContext = (nClassEndIndex < sContext.length()) ? sContext.substring(nClassEndIndex + 1) : "";
String sMethod = getMethod();
if (metaclass == null && sMethod.equals(HTTP.METHOD_GET))
{
// Generate schema
XSDGenerator generator;
if (getParameter("xsd") != null)
{
generator = new XSDGenerator();
}
else if (m_bWrapped)
{
if (getParameter("basic") != null)
{
generator = new WSDLBasicGenerator(SOAP_ACTION_BASIC);
}
else
{
generator = new WSDLGenerator(SOAP_ACTION_DEFAULT);
}
}
else
{
generator = new WADLGenerator();
}
generator.setCompatible(StringUtil.isEmpty(getParameter("compatible")) ||
StringUtil.parseBoolean(getParameter("compatible")));
generator.setIncludeDocumentation(getParameter("doc") != null);
String sMask = getParameter("mask");
if (sMask != null)
{
generator.setMask(sMask.split("\\s+"));
}
String sScope = getParameter("scope");
if ("none".equals(sScope) || "generic".equals(sScope))
{
generator.setScope(XSDGenerator.SCOPE_GENERIC);
}
else if ("state".equals(sScope))
{
generator.setScope(XSDGenerator.SCOPE_STATE);
}
else if ("behavior".equals(sScope) || "behaviour".equals(sScope))
{
generator.setScope(XSDGenerator.SCOPE_BEHAVIOUR);
}
else if (sScope != null)
{
throw new IllegalArgumentException("Invalid SCOPE value.");
}
List metaclassList = Collections.list(new IteratorEnumeration(m_context.getMetadata().getMetaclassIterator()));
Collections.sort(metaclassList, Metaclass.COMPARATOR);
setResponseContentType(generator.getMIMEType());
Writer writer = getWriter();
writer.write(XML_HEADER);
generator.generate(writer, metaclassList.iterator(), m_request.getRequestURL().toString());
}
else
{
// Invoke the generic server
Object request;
try
{
request = unmarshal(metaclass, sContext);
}
catch (Exception e)
{
if (e instanceof ClassCastException ||
e instanceof NumberFormatException ||
e instanceof TypeConversionException)
{
throw new RequestException("err.rpc.xml.request", e);
}
throw e;
}
Server server = (Server)m_server.getInstance(m_context);
Object response;
if (request instanceof Invoker)
{
Invoker invoker = (Invoker)request;
invoker.setLocale(m_request.getLocale());
response = invoker.invoke(server);
}
else if (request instanceof Request)
{
response = server.invoke((Request)request);
}
else
{
throw new RequestException("err.rpc.xml.request");
}
if (sMethod.equals(HTTP.METHOD_DELETE))
{
return;