                        PowerLoom SOAP Server

The SOAP server will need to be hosted on a web services platform such
as Tomcat (Java) or AllegroServe (Common Lisp).  To use the SOAP
server for PowerLoom, you will need to connect to the SOAP server
using the POST method of the HTTP protocol.  The web address of the
powerloom SOAP server will be:

   http://your.host.here:port/ploom/soapserver

and messages with the standard SOAP envelope encoding should be sent
to that location.

The namespace used by the SOAP server is

   http://www.isi.edu/powerloom/

Currently, the SOAP server understands the following messages:

command:  Execute a PowerLoom command as if at the top level command
          loop.  This is the most general of the supported messages.
          As a convenience the other messages provide a more
          specialized protocol for interaction.

assertion   Assert a PowerLoom sentence.  Returns the propositions
            that were actually asserted.

retraction  Retract a PowerLoom sentence.  Returns the propositions
            that were actually retracted.

ask    Ask a yes/no query.  It will return TRUE, FALSE or UNKNOWN.

retrieval  Ask a query with unbound variables.  The return value will
           be a set of tuples whose structure depends on the
           particular query's pattern, similar to the way that
           PowerLoom's retrieve command returns values.

All of the messages need to specify the module in which they are to
operate.  A detailed look at the message format is provided below:

<command>
  <module>MNAME</module>
  COMMAND TEXT HERE
</command>

<assertion>
  <module>MNAME</module>
  POWERLOOM SENTENCE HERE
</assertion>

<retraction>
  <module>MNAME</module>
  POWERLOOM SENTENCE HERE
</retraction>

<ask>
  <module>MNAME</module>
  <options>QUERY OPTIONS HERE -- OPTIONAL</options>
  POWERLOOM QUERY HERE
</ask>

<retrieval>
  <module>MNAME</module>
  <nresults>NUMBER OF RESULTS TO RETURN OR "ALL" -- OPTIONAL</nresults>
  <pattern>VARIABLE PATTERN -- OPTIONAL</pattern>
  <options>QUERY OPTIONS HERE -- OPTIONAL</options>
  POWERLOOM QUERY HERE
</retrieval>

The values that are returned are as follows:

command:    <result>STRING RETURNED BY POWERLOOM</result>

assertion:
retraction:  <propositions>
                <nresults>NUMBER OF PROPOSITIONS</nresults>
                <proposition>PROPOSITION 1</proposition>
                <proposition>PROPOSITION 2</proposition>
                ...
             </propositions>

ask:        <answer>
              <query>QUERY</query>
              <result>ANSWER</result>
            <answer>

retrieval  <tuples>
             <nresults>NUMBER OF TUPLES RETURNED</nresults>
             <query>QUERY</query>
             <pattern>VARIABLE PATTERN in parentheses</pattern>
             <tuple>
                <nresults>NUMBER OF ITEMS IN TUPLE</nresults>
                <item>ITEM 1,1</item>
                <item>ITEM 1,2</item>
                ...
             </tuple>
             <tuple>
                <nresults>NUMBER OF ITEMS IN TUPLE</nresults>
                <item>ITEM 2,1</item>
                <item>ITEM 2,2</item>
                ...
             </tuple>
           </tuples>


Examples of usage:

------------------------------------------------------------------------
<command>
  <module>PL-USER</module>
  (defconcept Person)
</command>

returns

<PLSOAP:result xmlns:PLSOAP="http://www.isi.edu/powerloom/">PERSON</PLSOAP:result>
  
------------------------------------------------------------------------

<assertion>
  <module>PL-USER</module>
  (and (person Fred) (person Barney))
</assertion>

returns

<PLSOAP:propositions xmlns:PLSOAP="http://www.isi.edu/powerloom/">
      <PLSOAP:nresults xmlns:XSI="http://www.w3.org/2001/XMLSchema-instance" xmlns:XSD="http://www.w3.org/2001/XMLSchema" XSI:type="XSD:int">2</PLSOAP:nresults>
      <PLSOAP:proposition>(PERSON FRED)</PLSOAP:proposition>
      <PLSOAP:proposition>(PERSON BARNEY)</PLSOAP:proposition>
 </PLSOAP:propositions>

------------------------------------------------------------------------

<retrieval>
  <module>PL-USER</module>
  (and (person ?x) (person ?y))
</retrieval>

returns

<PLSOAP:tuples xmlns:PLSOAP="http://www.isi.edu/powerloom/">
  <PLSOAP:nresults xmlns:XSI="http://www.w3.org/2001/XMLSchema-instance" xmlns:XSD="http://www.w3.org/2001/XMLSchema" XSI:type="XSD:int">1</PLSOAP:nresults>
    <PLSOAP:pattern>(?X ?Y)</PLSOAP:pattern>
   <PLSOAP:tuple>
     <PLSOAP:nresults xmlns:XSI="http://www.w3.org/2001/XMLSchema-instance" xmlns:XSD="http://www.w3.org/2001/XMLSchema" XSI:type="XSD:int">2</PLSOAP:nresults>
     <PLSOAP:item>BARNEY</PLSOAP:item>
     <PLSOAP:item>BARNEY</PLSOAP:item>
   </PLSOAP:tuple>
</PLSOAP:tuples>
  
------------------------------------------------------------------------

<retrieval>
  <module>PL-USER</module>
  <nresults>ALL</nresults>
  (and (person ?x) (person ?y))
</retrieval>

returns

<PLSOAP:tuples xmlns:PLSOAP="http://www.isi.edu/powerloom/">
  <PLSOAP:nresults xmlns:XSI="http://www.w3.org/2001/XMLSchema-instance" xmlns:XSD="http://www.w3.org/2001/XMLSchema" XSI:type="XSD:int">4</PLSOAP:nresults>
  <PLSOAP:pattern>(?X ?Y)</PLSOAP:pattern>
  <PLSOAP:tuple>
    <PLSOAP:nresults xmlns:XSI="http://www.w3.org/2001/XMLSchema-instance" xmlns:XSD="http://www.w3.org/2001/XMLSchema" XSI:type="XSD:int">2</PLSOAP:nresults>
    <PLSOAP:item>BARNEY</PLSOAP:item>
    <PLSOAP:item>BARNEY</PLSOAP:item>
  </PLSOAP:tuple>
  <PLSOAP:tuple>
    <PLSOAP:nresults xmlns:XSI="http://www.w3.org/2001/XMLSchema-instance" xmlns:XSD="http://www.w3.org/2001/XMLSchema" XSI:type="XSD:int">2</PLSOAP:nresults>
    <PLSOAP:item>BARNEY</PLSOAP:item>
    <PLSOAP:item>FRED</PLSOAP:item>
  </PLSOAP:tuple>
  <PLSOAP:tuple>
    <PLSOAP:nresults xmlns:XSI="http://www.w3.org/2001/XMLSchema-instance" xmlns:XSD="http://www.w3.org/2001/XMLSchema" XSI:type="XSD:int">2</PLSOAP:nresults>
    <PLSOAP:item>FRED</PLSOAP:item>
    <PLSOAP:item>BARNEY</PLSOAP:item>
  </PLSOAP:tuple>
  <PLSOAP:tuple>
    <PLSOAP:nresults xmlns:XSI="http://www.w3.org/2001/XMLSchema-instance" xmlns:XSD="http://www.w3.org/2001/XMLSchema" XSI:type="XSD:int">2</PLSOAP:nresults>
    <PLSOAP:item>FRED</PLSOAP:item>
    <PLSOAP:item>FRED</PLSOAP:item>
  </PLSOAP:tuple>
</PLSOAP:tuples>

------------------------------------------------------------------------
