You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by sa...@locus.apache.org on 2000/08/10 04:25:59 UTC

cvs commit: xml-soap/java/webapps/soap/rpcrouter rpcrouter.jsp

sanjiva     00/08/09 19:25:59

  Added:       java/webapps/soap index.html
               java/webapps/soap/WEB-INF web.xml
               java/webapps/soap/admin blankpage.html deploy.gif deploy.jsp
                        header.html index.html list.gif list.jsp
                        showdetails.jsp soapadmin.gif toc.html undeploy.gif
                        undeploy.jsp
               java/webapps/soap/rpcrouter rpcrouter.jsp
  Log:
  created a new webapp called "soap" with the servlet and the admin client
  (and the old rpcrouter.jsp for now) all in the same webapp.
  
  Revision  Changes    Path
  1.1                  xml-soap/java/webapps/soap/index.html
  
  Index: index.html
  ===================================================================
  <html>
  
  <head>
  <meta http-equiv="Content-Type"
  content="text/html; charset=iso-8859-1">
  <meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
  <title></title>
  </head>
  
  <body bgcolor="#FFFFFF">
  
  <h1 align="center">Apache SOAP</h1>
  
  <p>Hello! <em>Welcome</em> to the Apache SOAP.</p>
  
  <p>What do you want to do today?</p>
  
  <ul>
      <li><a href="admin">Run</a> the admin client</li>
      <li><a href="servlet/rpcrouter">Visit</a> the SOAP RPC router
          URL for this SOAP server</li>
  </ul>
  </body>
  </html>
  
  
  
  1.1                  xml-soap/java/webapps/soap/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
  
  <web-app>
      <servlet>
          <servlet-name>
              rpcrouter
          </servlet-name>
          <servlet-class>
              org.apache.soap.server.http.RPCRouterServlet
          </servlet-class>
          <init-param>
              <param-name>ServicesStore</param-name>
              <param-value>DeployedServices.ds</param-value>
          </init-param>
      </servlet>
  </web-app>
  
  
  
  1.1                  xml-soap/java/webapps/soap/admin/blankpage.html
  
  Index: blankpage.html
  ===================================================================
  <b>What do you want to do today?</b>
  
  
  
  1.1                  xml-soap/java/webapps/soap/admin/deploy.gif
  
  	<<Binary file>>
  
  
  1.1                  xml-soap/java/webapps/soap/admin/deploy.jsp
  
  Index: deploy.jsp
  ===================================================================
  <%@ page import="java.io.*, java.util.*, org.w3c.dom.*" %>
  <%@ page import="org.apache.soap.util.*, org.apache.soap.util.xml.*, org.apache.soap.server.*" %>
  
  <!-- get the serviceManager object -->
  <jsp:useBean id="serviceManager" 
               class="org.apache.soap.server.ServiceManager"
               scope="application">
  </jsp:useBean>
  
  <h1>Deploy a Service</h1>
  
  <% 
  if (!request.getMethod().equals ("POST")) { 
  %>
  
  <form action="deploy.jsp" method="POST">
      <table border="1" width="100%">
          <tr>
              <th colspan="2"><h2>Service Deployment Descriptor
              Template</h2>
              </th>
          </tr>
          <tr>
              <th>Property</th>
              <th>Details</th>
          </tr>
          <tr>
              <td>ID</td>
              <td><input type="text" size="60" name="id"></td>
          </tr>
          <tr>
              <td>Scope</td>
              <td><select name="scope" size="1">
                  <option selected value="0">Page</option>
                  <option value="1">Request</option>
                  <option value="2">Session</option>
                  <option value="3">Application</option>
              </select></td>
          </tr>
          <tr>
              <td>Methods</td>
              <td><input type="text" size="60" name="methods"><br>
              (Whitespace separated list of method names) </td>
          </tr>
          <tr>
              <td>Provider Type</td>
              <td><select name="providerType" size="1">
                  <option selected value="0">Java</option>
                  <option value="1">Script</option>
              </select></td>
          </tr>
          <tr>
              <td>Java Provider</td>
              <td><div align="left"><table border="0">
                  <tr>
                      <td>Provider Class</td>
                      <td><input type="text" size="40"
                      name="providerClass"></td>
                  </tr>
                  <tr>
                      <td width="150">Static?</td>
                      <td><select name="isStatic" size="1">
                          <option value="true">Yes</option>
                          <option selected value="no">No</option>
                      </select></td>
                  </tr>
              </table>
              </div></td>
          </tr>
          <tr>
              <td>Script Provider</td>
              <td><div align="left"><table border="0">
                  <tr>
                      <td>Script Language</td>
                      <td><select name="scriptLanguage" size="1">
                          <option value="bml">BML</option>
                          <option value="jacl">Jacl</option>
                          <option value="javascript">JavaScript (Rhino)</option>
                          <option value="jpython">JPython</option>
                          <option value="jscript">JScript</option>
                          <option value="perlscript">PerlScript</option>
                          <option value="vbscript">VBScript</option>
                          <option value="other">Other .. (type in)</option>
                      </select><input type="text" size="20"
                      name="scriptLanguageTypein"></td>
                  </tr>
                  <tr>
                      <td width="150">Script Filename, or</td>
                      <td><input type="text" size="40"
                      name="scriptFilename"></td>
                  </tr>
                  <tr>
                      <td>Script</td>
                      <td><textarea name="script" rows="10"
                      cols="40"></textarea></td>
                  </tr>
              </table>
              </div></td>
          </tr>
          <tr>
              <td>Type Mappings</td>
              <td>Number of mappings: <input type="text" size="10"
              name="nmaps" /><br>
              <div align="center"><center><table border="0">
                  <tr>
                      <td align="center" rowspan="2">Encoding Style</td>
                      <td align="center" colspan="2">Element Type </td>
                      <td align="center" rowspan="2">Java Type</td>
                      <td align="center" rowspan="2">Java to XML
                      Serializer </td>
                      <td align="center" rowspan="2">XML to Java
                      Deserializer </td>
                  </tr>
                  <tr>
                      <td align="center">Namespace URI</td>
                      <td align="center">Local Part</td>
                  </tr>
                  <tr>
                      <td><select name="encstyle1" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri1"></td>
                      <td><input type="text" size="10"
                      name="localpart1"></td>
                      <td><input type="text" size="15"
                      name="classname1"></td>
                      <td><input type="text" size="15"
                      name="java2xml1"></td>
                      <td><input type="text" size="15"
                      name="xml2java1"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle2" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri2"></td>
                      <td><input type="text" size="10"
                      name="localpart2"></td>
                      <td><input type="text" size="15"
                      name="classname2"></td>
                      <td><input type="text" size="15"
                      name="java2xml2"></td>
                      <td><input type="text" size="15"
                      name="xml2java2"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle3" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri3"></td>
                      <td><input type="text" size="10"
                      name="localpart3"></td>
                      <td><input type="text" size="15"
                      name="classname3"></td>
                      <td><input type="text" size="15"
                      name="java2xml3"></td>
                      <td><input type="text" size="15"
                      name="xml2java3"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle4" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri4"></td>
                      <td><input type="text" size="10"
                      name="localpart4"></td>
                      <td><input type="text" size="15"
                      name="classname4"></td>
                      <td><input type="text" size="15"
                      name="java2xml4"></td>
                      <td><input type="text" size="15"
                      name="xml2java4"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle5" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri5"></td>
                      <td><input type="text" size="10"
                      name="localpart5"></td>
                      <td><input type="text" size="15"
                      name="classname5"></td>
                      <td><input type="text" size="15"
                      name="java2xml5"></td>
                      <td><input type="text" size="15"
                      name="xml2java5"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle6" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri6"></td>
                      <td><input type="text" size="10"
                      name="localpart6"></td>
                      <td><input type="text" size="15"
                      name="classname6"></td>
                      <td><input type="text" size="15"
                      name="java2xml6"></td>
                      <td><input type="text" size="15"
                      name="xml2java6"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle7" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri7"></td>
                      <td><input type="text" size="10"
                      name="localpart7"></td>
                      <td><input type="text" size="15"
                      name="classname7"></td>
                      <td><input type="text" size="15"
                      name="java2xml7"></td>
                      <td><input type="text" size="15"
                      name="xml2java7"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle8" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri8"></td>
                      <td><input type="text" size="10"
                      name="localpart8"></td>
                      <td><input type="text" size="15"
                      name="classname8"></td>
                      <td><input type="text" size="15"
                      name="java2xml8"></td>
                      <td><input type="text" size="15"
                      name="xml2java8"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle9" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri9"></td>
                      <td><input type="text" size="10"
                      name="localpart9"></td>
                      <td><input type="text" size="15"
                      name="classname9"></td>
                      <td><input type="text" size="15"
                      name="java2xml9"></td>
                      <td><input type="text" size="15"
                      name="xml2java9"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle10" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri10"></td>
                      <td><input type="text" size="10"
                      name="localpart10"></td>
                      <td><input type="text" size="15"
                      name="classname10"></td>
                      <td><input type="text" size="15"
                      name="java2xml10"></td>
                      <td><input type="text" size="15"
                      name="xml2java10"></td>
                  </tr>
              </table>
              </center></div></td>
          </tr>
      </table>
      <p><input type="submit" value="Deploy" /></p>
  </form>
  
  <%
  } else {
    String id = request.getParameter ("id");
    DeploymentDescriptor dd = new DeploymentDescriptor ();
    dd.setID (id);
  
    // get the provider info
    int scope = Integer.parseInt (request.getParameter ("scope"));
    String providerTypeStr = request.getParameter ("providerType");
    String className = request.getParameter ("providerClass");
    boolean isStatic = request.getParameter ("isStatic").equals ("true");
    String scriptLang = request.getParameter ("scriptLanguage");
    if (scriptLang.equals ("other")) {
      scriptLang = request.getParameter ("scriptLanguageTypeIn");
    }
    String scriptFilename = request.getParameter ("scriptFilename");
    String script = request.getParameter ("script");
    String methodsStr = request.getParameter ("methods");
    StringTokenizer st = new StringTokenizer (methodsStr);
    int nTokens = st.countTokens ();
    String[] methods = new String[nTokens];
    for (int i = 0; i < nTokens; i++) {
      methods[i] = st.nextToken ();
    }
  
    dd.setScope (scope);
    dd.setMethods (methods);
  
    if (providerTypeStr.equals ("0")) {
      dd.setProviderType (DeploymentDescriptor.PROVIDER_JAVA);
      dd.setProviderClass (className);
      dd.setIsStatic (isStatic);
    } else {
      if (!scriptFilename.equals ("")) { // filename specified
        dd.setProviderType (DeploymentDescriptor.PROVIDER_SCRIPT_FILE);
      } else { // there better be a script to run
        dd.setProviderType (DeploymentDescriptor.PROVIDER_SCRIPT_STRING);
      }
      dd.setScriptLanguage (scriptLang);
      dd.setScriptFilenameOrString (scriptFilename);
    }
  
    String[] encs = {org.apache.soap.Constants.NS_URI_SOAP_ENC,
         org.apache.soap.Constants.NS_URI_XMI_ENC};
  
    // set up any type mappings
    int nmaps = 0;
  
    try {
      nmaps = Integer.parseInt (request.getParameter ("nmaps"));
    } catch (NumberFormatException e) {
    }
  
    if (nmaps != 0) {
      TypeMapping[] mappings = new TypeMapping[nmaps];
      for (int i = 1; i <= nmaps; i++) { // the form is hard-coded to a max of 10
        int encStyle = Integer.parseInt (request.getParameter ("encstyle" + i));
        String nsuri = request.getParameter ("nsuri" + i);
        String localPart = request.getParameter ("localpart" + i);
        String classNameStr = request.getParameter ("classname" + i);
        String java2XMLClass = request.getParameter ("java2xml" + i);
        String xml2JavaClass = request.getParameter ("xml2java" + i);
        QName elementType = (nsuri.equals ("") || localPart.equals ("")) 
                            ? null : new QName (nsuri, localPart);
        // map "" to null (the unfilled params come as empty strings because
        // they are infact actual parameters)
        classNameStr = classNameStr.equals ("") ? null : classNameStr;
        java2XMLClass = java2XMLClass.equals ("") ? null : java2XMLClass;
        xml2JavaClass = xml2JavaClass.equals ("") ? null : xml2JavaClass;
        mappings[i-1] = new TypeMapping (encs[encStyle], elementType,
  				       classNameStr, java2XMLClass,
  				       xml2JavaClass);
      }
      dd.setMappings (mappings);
    }
  
    // ok now deploy it
    serviceManager.deploy (dd);
  
    // show what was deployed
    out.println ("<p>Service <b>" + dd.getID () + "</b> deployed.</p>");
  }
  %>
  
  
  
  1.1                  xml-soap/java/webapps/soap/admin/header.html
  
  Index: header.html
  ===================================================================
  <center>
  <img src="soapadmin.gif"/>
  </center>
  
  
  
  1.1                  xml-soap/java/webapps/soap/admin/index.html
  
  Index: index.html
  ===================================================================
  <html>
    <head>
      <title>IBM-SOAP Admin Tool</title>
  
      <script language="JavaScript" type="text/javascript">
        <!-- Hide from non-scripting browsers
        function refresh()
        {
          toc.location.reload();
          data.location.href='blankpage.html';
        }
        // -->
      </script>
    </head>
  
    <frameset rows="90,*" border="0">
      <frame name="image" src="header.html">
      <frameset cols="150,*" border="0">
        <frame name="toc" src="toc.html">
        <frame name="data" src="blankpage.html">
      </frameset>
    </frameset>
  </html>
  
  
  
  1.1                  xml-soap/java/webapps/soap/admin/list.gif
  
  	<<Binary file>>
  
  
  1.1                  xml-soap/java/webapps/soap/admin/list.jsp
  
  Index: list.jsp
  ===================================================================
  <%@ page import="java.util.*, org.apache.soap.server.*" %>
  
  <!-- get the serviceManager object -->
  <jsp:useBean id="serviceManager" 
               class="org.apache.soap.server.ServiceManager"
               scope="application">
  </jsp:useBean>
  
  <h1>Service Listing</h1>
  
  <% 
    String[] serviceNames = serviceManager.list ();
    if (serviceNames.length == 0) {
      out.println ("<p>Sorry, there are no services currently deployed.</p>");
    } else {
      out.println ("<p>Here are the deployed services (select one to see");
      out.println ("details)</p>");
      %>
      <ul>
      <%
      for (int i = 0; i < serviceNames.length; i++) {
        String id = serviceNames[i];
      %>
        <li><a href="showdetails.jsp?id=<%=id%>"><%= id%></li>
      <%
      }
      %>
      </ul>
      <%
    }
  %>
  
  
  
  1.1                  xml-soap/java/webapps/soap/admin/showdetails.jsp
  
  Index: showdetails.jsp
  ===================================================================
  <%@ page import="java.util.*, org.apache.soap.server.*, org.apache.soap.util.xml.*" %>
  
  <!-- get the serviceManager object -->
  <jsp:useBean id="serviceManager" 
               class="org.apache.soap.server.ServiceManager"
               scope="application">
  </jsp:useBean>
  
  <h1>Deployed Service Information</h1>
  
  <% 
    String id = request.getParameter ("id");
    DeploymentDescriptor dd = (id != null) 
                              ? serviceManager.query (id) 
  			    : null;
    String[] scopes = {"Page", "Request", "Session", "Application"}; 
  
    if (id == null) {
      out.println ("<p>Huh? You hafta select a service to display ..</p>");
    } else if (dd == null) {
      out.println ("<p>Service '" + id + "' is not known.</p>");
    } else {
      out.println ("<table border='1' width='100%'>");
      out.println ("<tr>");
      out.println ("<th colspan='2'><h2>'" + id + 
  		 "' Service Deployment Descriptor</h2></th>");
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<th>Property</th>");
      out.println ("<th>Details</th>");
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<td>ID</td>");
      out.println ("<td>" + dd.getID()+ "</td>");
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<td>Scope</td>");
      out.println ("<td>" + scopes[dd.getScope()]+ "</td>");
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<td>Provider Type</td>");
      byte ptb = dd.getProviderType ();
      String pt = (ptb==DeploymentDescriptor.PROVIDER_JAVA) ? "java" : "script";
      out.println ("<td>" + pt + "</td>");
      out.println ("</tr>");
      out.println ("<tr>");
      if (ptb == DeploymentDescriptor.PROVIDER_JAVA) {
        out.println ("<td>Provider Class</td>");
        out.println ("<td>" + dd.getProviderClass()+ "</td>");
        out.println ("</tr>");
        out.println ("<tr>");
        out.println ("<td>Use Static Class</td>");
        out.println ("<td>" + dd.getIsStatic()+ "</td>");
      } else {
        out.println ("<td>Scripting Language</td>");
        out.println ("<td>" + dd.getScriptLanguage () + "</td>");
        out.println ("</tr>");
        out.println ("<tr>");
        if (ptb == DeploymentDescriptor.PROVIDER_SCRIPT_FILE) {
  	out.println ("<td>Filename</td>");
  	out.println ("<td>" + dd.getScriptFilenameOrString () + "</td>");
        } else {
  	out.println ("<td>Script</td>");
  	out.println ("<td><pre>" + dd.getScriptFilenameOrString () +
  		     "</pre></td>");
        }
      }
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<td>Methods</td>");
      out.print ("<td>");
      String[] m = dd.getMethods ();
      for (int i = 0; i < m.length; i++) {
        out.print (m[i]);
        if (i < m.length-1) {
  	out.print (", ");
        }
      }
      out.println ("</td>");
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<td>Type Mappings</td>");
      out.println ("<td>");
      TypeMapping[] mappings = dd.getMappings();
      if (mappings != null) {
        for (int i = 0; i < mappings.length; i++) {
  	out.print (mappings[i]);
  	if (i < mappings.length-1) {
  	  out.print ("<br>");
  	} else {
  	  break;
  	}
        }
      }
      out.println ("</td>");
      out.println ("</tr>");
      out.println ("</table>");
    }
  %>
  
  
  
  1.1                  xml-soap/java/webapps/soap/admin/soapadmin.gif
  
  	<<Binary file>>
  
  
  1.1                  xml-soap/java/webapps/soap/admin/toc.html
  
  Index: toc.html
  ===================================================================
  
  <body bgcolor='lightgreen'>
  <a href="list.jsp" target="data"><img src="list.gif"/></a>
  <p/>
  <a href="deploy.jsp" target="data"><img src="deploy.gif"/></a><br/>
  <p/>
  <a href="undeploy.jsp" target="data"><img src="undeploy.gif"/></a><br/>
  </body>
  
  
  
  1.1                  xml-soap/java/webapps/soap/admin/undeploy.gif
  
  	<<Binary file>>
  
  
  1.1                  xml-soap/java/webapps/soap/admin/undeploy.jsp
  
  Index: undeploy.jsp
  ===================================================================
  <%@ page import="org.apache.soap.*" %>
  <%@ page import="org.apache.soap.server.*" %>
  
  <!-- get the serviceManager object -->
  <jsp:useBean id="serviceManager" 
               class="org.apache.soap.server.ServiceManager"
               scope="application">
  </jsp:useBean>
  
  <h1>Un-Deploy a Service</h1>
  
  <% 
  String id = request.getParameter ("id");
  if (id == null) {
    String[] serviceNames = serviceManager.list ();
    if (serviceNames.length == 0) {
      out.println ("<p>Sorry, there are no services currently deployed.</p>");
    } else {
      out.println ("<p>Select the service to be undeployed:</p>");
      %>
      <ul>
      <%
      for (int i = 0; i < serviceNames.length; i++) {
        id = serviceNames[i];
      %>
        <li><a href="undeploy.jsp?id=<%=id%>"><%= id%></li>
      <%
      }
      %>
      </ul>
      <%
    }
  } else {
    try {
      DeploymentDescriptor dd = serviceManager.undeploy (id);
      out.println ("OK, service named '" + id + "' undeployed successfully!");
    } catch (SOAPException e) {
      out.println ("Ouch, coudn't undeploy service '" + id + "' because: ");
      e.getMessage ();
    }
  }
  %>
  
  
  
  1.1                  xml-soap/java/webapps/soap/rpcrouter/rpcrouter.jsp
  
  Index: rpcrouter.jsp
  ===================================================================
  <%@ page language="java" %>
  
  <%@ page import="java.io.*" %>
  <%@ page import="java.util.*" %>
  <%@ page import="java.lang.reflect.*" %>
  <%@ page import="org.w3c.dom.*" %>
  <%@ page import="org.apache.soap.util.Bean" %>
  <%@ page import="org.apache.soap.util.MethodUtils" %>
  <%@ page import="org.apache.soap.util.IOUtils" %>
  <%@ page import="org.apache.soap.util.StringUtils" %>
  <%@ page import="org.apache.soap.util.xml.XMLParserLiaison" %>
  <%@ page import="org.apache.soap.util.xml.XercesParserLiaison" %>
  <%@ page import="org.apache.soap.*" %>
  <%@ page import="org.apache.soap.encoding.*" %>
  <%@ page import="org.apache.soap.rpc.*" %>
  <%@ page import="org.apache.soap.server.*" %>
  
  <jsp:useBean id="serviceManager"
               class="org.apache.soap.server.ServiceManager"
               scope="application">
  </jsp:useBean>
  
  <jsp:useBean id="rpcRouter"
               class="org.apache.soap.server.RPCRouter"
               scope="application">
  </jsp:useBean>
  
  <%
  // this should be done like this:
  //<jsp:setProperty name="rpcRouter" property="serviceManager" 
  //                 value="serviceManager"/>
  // but I get an internal servlet exception from tomcat for it ..
  rpcRouter.setServiceManager (serviceManager);
  
  Response resp = null;
  String targetID = null;
  
  // Query the relevant header fields.
  String requestMethod = request.getMethod ();
  String contentType = request.getContentType ();
  int contentLength = request.getContentLength ();
  
  Call call = null;
  
  if (!requestMethod.equals (Constants.HEADER_POST))
  {
    out.println ("Sorry, I only talk via POST.");
  } 
  else if (contentType == null
  	 || !contentType.equals (Constants.HEADERVAL_CONTENT_TYPE))
  {
    out.println ("Content type must be: '" + 
  	       Constants.HEADERVAL_CONTENT_TYPE + "'.");
  }
  else if (contentLength < 0)
  {
    out.println ("Content length must be specified.");
  }
  else
  {
    try
    {
      System.err.println (">>(" + new Date() +
                          ") Processing SOAP request...");
  
      response.setContentType (Constants.HEADERVAL_CONTENT_TYPE);
  
      Reader requestReader = request.getReader ();
      char[] payload       = new char[contentLength];
      int    offset        = 0;
  
      while (offset < contentLength) {
        offset += requestReader.read (payload, offset, contentLength - offset);
      }
  
      // Parse the incoming request stream.
      org.apache.soap.util.xml.XMLParserLiaison xpl = new XercesParserLiaison ();
      Document callDoc = xpl.read("- SOAP HTTP RPC Call Envelope -",
                                  new CharArrayReader (payload));
      Element payloadEl = null;
  
      if (callDoc == null) {
        throw new SOAPException(Constants.FAULT_CODE_PROTOCOL,
                                "DOM parsing error: " + payload);
      }
  
      // get the call out
      try {
        payloadEl = callDoc.getDocumentElement ();
        Envelope callEnv = Envelope.unmarshall (payloadEl);
        call = rpcRouter.extractCallFromEnvelope (callEnv);
        targetID = call.getTargetObjectURI ();
      } catch (IllegalArgumentException e) {
        String msg = e.getMessage ();
        String faultCode = (msg != null
                            && msg.equals(Constants.ERR_MSG_VERSION_MISMATCH))
                           ? Constants.FAULT_CODE_VERSION_MISMATCH
                           : Constants.FAULT_CODE_CLIENT;
  
        throw new SOAPException (faultCode, msg, e);
      }
  
      // call on a valid method name?
      if (!rpcRouter.validCall (call)) {
        throw new SOAPException (Constants.FAULT_CODE_SERVER,
                                 "Method '" + call.getMethodName () + 
  			       "' is not supported.");
      }
  
      // lifecycle stuff of target object: what's the class to instantiate?
      DeploymentDescriptor dd = serviceManager.query (targetID);
      int scope = dd.getScope ();
      byte providerType = dd.getProviderType ();
      String className;
      Object targetObject = null;
      if (providerType == DeploymentDescriptor.PROVIDER_JAVA) {
        className = dd.getProviderClass ();
      } else {
        // for scripts, we need a new BSF manager basically
        className = "com.ibm.bsf.BSFManager";
      }
  
      // determine the scope and lock object to use to manage the lifecycle
      // of the service providing object
      int[] iScopes = {PageContext.PAGE_SCOPE, PageContext.REQUEST_SCOPE,
  			    PageContext.SESSION_SCOPE,
  			    PageContext.APPLICATION_SCOPE};
      int iScope = iScopes[scope];
      Object[] scopeLocks = {pageContext, request, session, application};
      Object scopeLock = scopeLocks[scope];
  
      boolean freshObject = false;
  
      // find the target object on which the requested method should
      // be invoked
      if (targetID.equals (ServerConstants.SERVICE_MANAGER_SERVICE_NAME)) {
        targetObject = serviceManager;
      } else {
        // locate (or create) the target object and invoke the method
        synchronized (scopeLock) {
          targetObject = pageContext.getAttribute (targetID, iScope);
          if (targetObject == null) {
            try {
              Class c = Class.forName (className);
              if (dd.getIsStatic ()) {
                targetObject = c;
              } else {
                targetObject = c.newInstance ();
              }
              freshObject = true;
            } catch (Exception e) {
  	    String msg;
  	    if (providerType == DeploymentDescriptor.PROVIDER_JAVA) {
  	      msg = "Unable to resolve target object: " + e.getMessage ();
  	    } else {
  	      msg = "Unable to load BSF: script services not available " +
  		"without BSF: " + e.getMessage ();
  	    }
              throw new SOAPException (
                RPCConstants.FAULT_CODE_SERVER_BAD_TARGET_OBJECT_URI,
                msg, e);
            }
          }
          pageContext.setAttribute (targetID, targetObject, iScope);
        }
      }
        
      // if script provider type and first time to it, then load and
      // exec the script
      if (providerType != DeploymentDescriptor.PROVIDER_JAVA &&
  	freshObject) {
        // find the class that provides the BSF services (done
        // this way via reflection to avoid a static dependency on BSF)
        Class bc = Class.forName ("org.apache.soap.server.InvokeBSF");
  
        // get the script string to exec
        String script = dd.getScriptFilenameOrString ();
        if (providerType == DeploymentDescriptor.PROVIDER_SCRIPT_FILE) {
  	String fileName = getServletContext().getRealPath (script);
  	script = IOUtils.getStringFromReader (new FileReader (fileName));
        }
        
        // exec it
        Class[] sig = {DeploymentDescriptor.class,
  		     Object.class,
  		     String.class};
        Method m = MethodUtils.getMethod (bc, "init", sig, true);
        m.invoke (null, new Object[] {dd, targetObject, script});
      }
  
      // invoke the method on the target object
      resp = rpcRouter.invoke (call, targetObject);
    }
    catch (SOAPException e)
    {
      Fault fault = new Fault ();
      String faultCode = e.getFaultCode ();
      String faultString = e.getMessage ();
  
      if (faultCode == null || 
  	faultCode.startsWith (Constants.FAULT_CODE_SERVER))
      {
        response.setStatus (ServerConstants.SC_INTERNAL_SERVER_ERROR);
      }
      else if (faultCode.startsWith (Constants.FAULT_CODE_CLIENT))
      {
        response.setStatus (ServerConstants.SC_BAD_REQUEST);
      }
  
      fault.setFaultCode (faultCode);
      fault.setFaultString (faultString);
      fault.setFaultActorURI (request.getRequestURI ());
  
      resp = new Response (null,
                           null,
                           fault,
                           null,
                           null,
                           null);
    }
    catch (Throwable t)
    {
      // some unknown error occurred .. let's send the stacktrace out
      // hoping it'll be useful to someone
      t.printStackTrace ();
      t.printStackTrace (new PrintWriter (out));
    }
  }
  
  // Send it out.
  if (resp != null)
  {
    try
    {
      // Build an envelope containing the response.
      Envelope respEnvelope = resp.buildEnvelope ();
      SOAPMappingRegistry smr = (call != null
                                 ? call.getSOAPMappingRegistry ()
                                 : new SOAPMappingRegistry());
  
      respEnvelope.marshall (out, smr);
  
      out.println (StringUtils.lineSeparator);
    }
    catch (IllegalArgumentException e)
    {
      throw new SOAPException (Constants.FAULT_CODE_SERVER, e.getMessage(), e);
    }
    catch (IOException e)
    {
      throw new SOAPException (Constants.FAULT_CODE_SERVER, e.getMessage(), e);
    }
  }
  %>