<?xml version="1.0" encoding="UTF-8"?>
<essay xml:lang="en" version="pto" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:gal="http://norman.walsh.name/rdf/gallery#">
<info>
    
    
    
    
    
    
<title>WITW: SOAP RPC (V2)</title><biblioid class="uri">http://norman.walsh.name/2005/02/24/soaprpc-2</biblioid>
<volumenum>8</volumenum>
<issuenum>32</issuenum>
<pubdate>2005-02-24T17:13:51-05:00</pubdate>
<date>$Date: 2006-07-14 10:06:19 -0400 (Fri, 14 Jul 2006) $</date>
<author>
      <personname>
<firstname>Norman</firstname>
	<surname>Walsh</surname>
</personname>
    </author>
<copyright>
      <year>2005</year>
      <holder>Norman Walsh</holder>
    </copyright>
<abstract>
<para>A revised SOAP RPC interface.</para>
</abstract>
<dcterms:replaces>http://norman.walsh.name/2005/02/18/witw-soaprpc</dcterms:replaces>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#WebServices"/>
</info>

<para xml:id="p1">I've revised
<link xlink:href="../18/witw-soaprpc">my second interface</link> to
<link xlink:href="../15/ws-wtf">Where In The World</link>.
It's still
a set of methods that you can invoke using
<link xlink:href="http://www.w3.org/TR/2003/soap12-part0/#L1185">SOAP RPC</link>,
but I've changed the methods so that they all return simple, scalar values.
I'm not sure I understand how SOAP is supposed to return arrays and
<emphasis>I'm sure</emphasis> I don't understand how to do it
<link xlink:href="wsdl">in WSDL</link>. So the
salient bits are now:</para>

<variablelist>
<varlistentry>
<term>The target SOAP node</term>
<listitem>
<para xml:id="p2">That's “<uri>http://norman.walsh.name/2005/02/soap/witw</uri>”
(Note the change: it's “<uri>/soap/witw</uri>” where it used to be
“<uri>/witw/soap</uri>”. Sorry, I know that's confusing; it's more fiddling
to do with authentication that's just not important today.)
That URI is for the 
“where is someone” services.
I'm not going to re-implement the “where I am” services in SOAP unless
someone actually tells me they want to use them.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>The namespace of the services</term>
<listitem>
<para xml:id="p3">That's “<uri>http://norman.walsh.name/witw</uri>”. I'd have made that a
dated URI, but I'm using
<link xlink:href="http://en.wikipedia.org/wiki/Perl">Perl</link>’s
<link xlink:href="http://cpan.uwinnipeg.ca/module/SOAP::Lite">SOAP::Lite</link>
module to do the implementation
and there was some weirdness in the way that the namespace
name was mapped to the Perl module name. I decided to just punt.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>The names of the methods</term>
<listitem>
<para xml:id="p4">They are “<methodname>name</methodname>”,
“<methodname>email</methodname>”,
“<methodname>uri</methodname>”,
“<methodname>latitude</methodname>”, “<methodname>longitude</methodname>”,
and “<methodname>date</methodname>” described below.</para>
</listitem>
</varlistentry>
</variablelist>

<para xml:id="p5">I've decomposed things differently again to
to make all the methods return simple scalars.</para>

<section xml:id="name">
<title>Name</title>

<para xml:id="p6">The <methodname>name</methodname> method returns
the full name of the person associated with
a <parameter>userid</parameter>:</para>

<methodsynopsis xml:id="f.name">
  <type>xs:string</type>
  <methodname>name</methodname>
  <methodparam>
    <type>xs:string</type>
    <parameter>userid</parameter>
  </methodparam>
  <exceptionname>UnknownUser</exceptionname>
</methodsynopsis>

<para xml:id="p7">It returns the full name of the user.</para>
<para xml:id="p8">If the specified <parameter>userid</parameter> is unknown,
the service faults.</para>
</section>

<section xml:id="email">
<title>Email</title>

<para xml:id="p9">The <methodname>email</methodname> method returns
the email address of the person associated with
a <parameter>userid</parameter>:</para>

<methodsynopsis xml:id="f.email">
  <type>xs:string</type>
  <methodname>email</methodname>
  <methodparam>
    <type>xs:string</type>
    <parameter>userid</parameter>
  </methodparam>
  <exceptionname>UnknownUser</exceptionname>
</methodsynopsis>

<para xml:id="p10">It returns a hash
(in the
<link xlink:href="http://xmlns.com/foaf/0.1/#term_mbox_sha1sum">mbox_sha1sum</link>-style
of <link xlink:href="http://en.wikipedia.org/wiki/FOAF">FOAF</link>)
of the user's <parameter>email</parameter> address.</para>
<para xml:id="p11">If the specified <parameter>userid</parameter> is unknown,
the service faults.</para>
</section>

<section xml:id="uri">
<title>Uri</title>

<para xml:id="p12">The <methodname>uri</methodname> method returns
the URI of the person associated with
a <parameter>userid</parameter>:</para>

<methodsynopsis xml:id="f.uri">
  <type>xs:string</type>
  <methodname>uri</methodname>
  <methodparam>
    <type>xs:string</type>
    <parameter>userid</parameter>
  </methodparam>
  <exceptionname>UnknownUser</exceptionname>
</methodsynopsis>

<para xml:id="p13">It returns the URI associated with a user.</para>
<para xml:id="p14">If the specified <parameter>userid</parameter> is unknown,
the service faults.</para>
</section>

<section xml:id="latlong">
<title>Latitude and Longitude</title>

<para xml:id="p15">The <methodname>latitude</methodname> and
<methodname>longitude</methodname> methods returns information about the
location of the specified <parameter>userid</parameter>.</para>

<methodsynopsis xml:id="f.latitude">
  <type>xs:float</type>
  <methodname>latitude</methodname>
  <methodparam>
    <type>xs:string</type>
    <parameter>userid</parameter>
  </methodparam>
  <exceptionname>UnknownUser</exceptionname>
  <exceptionname>UnknownLocation</exceptionname>
</methodsynopsis>

<methodsynopsis xml:id="f.longitude">
  <type>xs:float</type>
  <methodname>longitude</methodname>
  <methodparam>
    <type>xs:string</type>
    <parameter>userid</parameter>
  </methodparam>
  <exceptionname>UnknownUser</exceptionname>
  <exceptionname>UnknownLocation</exceptionname>
</methodsynopsis>

<para xml:id="p16">These methods return the latitude and longitude
of the specified user, respectively.</para>

<para xml:id="p17">The methods fault if the
<parameter>userid</parameter> is unknown or if the user has not
specified a location.</para>
</section>

<section xml:id="date">
<title>Date</title>

<para xml:id="p18">The <methodname>date</methodname> method returns the
when the position of the user was last updated.</para>

<methodsynopsis xml:id="f.date">
  <type>xs:dateTime</type>
  <methodname>date</methodname>
  <methodparam>
    <type>xs:string</type>
    <parameter>userid</parameter>
  </methodparam>
  <exceptionname>UnknownUser</exceptionname>
  <exceptionname>UnknownLocation</exceptionname>
</methodsynopsis>

<para xml:id="p19">It returns the date and time of the last time that
the users position was updated.</para>

<para xml:id="p20">The method faults if the
<parameter>userid</parameter> is unknown or if the user has not
specified a location.</para>
</section>

<section xml:id="sample">
<title>Sample Code</title>

<para xml:id="p21">On the assumption that any who's read this far won't be scared
off by a few lines of code, here's
<link xlink:href="examples/witw.soap.pl">a short Perl script</link>
that returns
the latitude and longitude of a user.</para>

<programlisting>
      <textobject>
<textdata fileref="examples/witw.soap.pl"/>
</textobject>
    </programlisting>

<para xml:id="p22">This evening, if you pass it <literal>ndw</literal>,
it tells you I'm at home:</para>

<programlisting><prompt>$</prompt> <command>perl</command> witw.soap.pl ndw
Norman Walsh was last seen at 42.34N, 72.45W.
That was on 2005-02-21T21:05:16Z.</programlisting>

<para>The brute force API still works
<link xlink:href="../18/witw-soaprpc#25">the same way</link>.
</para>

</section>
</essay>

