The idea is to encapsulate remotely invokable interfaces in SOAP in an ordinary RMI like way. A SOAP server publishes on one of its web pages a jar file with all:
<soap:Envelope xmlns:soap="http://www.w3.org/2002/06/soap-envelope" xmlns:rmi="http://www.ronaldkoster.net/soap-rmi_10.dtd" soap:encodingStyle="URL of publishing web page mentioned above">
Server side implementation
On the Server side for each remote interface <interfaceX> one or more instances of
implementing class <interfaceX>Server are running that parse all incoming SOAP requests,
executes the request and translates the output to a SOAP response.
NB. Terminology: an object is an instance of a class or interface;
Example: all exceptions can be made stringable. Here is an example of such a stringable exception: ExceptionTooManySessions.
...
Kalender kal = new KalenderClient();
...
kal.getDayOfWeek(2002, 9, 25);
Resulting Request:
<soap:Envelope
xmlns:soap="http://www.w3.org/2002/06/soap-envelope"
xmlns:rmi="http://www.ronaldkoster.net/soap-rmi_10.dtd"
soap:encodingStyle="http://www.ronaldkoster.net/soap-rmi.htm">
<soap:Body>
<rmi:request interface="Kalender" methode="getDayOfWeek" type="String">
<rmi:param name="year" type="int">2002</rmi:param>
<rmi:param name="month" type="int">9</rmi:param>
<rmi:param name="day" type="int">25</rmi:param>
</rmi:request>
</soap:Body>
</soap:Envelope>
Response:
<soap:Envelope
xmlns:soap="http://www.w3.org/2002/06/soap-envelope"
xmlns:rmi="http://www.ronaldkoster.net/soap-rmi_10.dtd"
soap:encodingStyle="http://www.ronaldkoster.net/soap-rmi.htm">
<soap:Body>
<rmi:response interface="Kalender" method="getDayOfWeek" type="String">
<rmi:return>Wednesday</rmi:return>
</rmi:response>
</soap:Body>
</soap:Envelope>
In the following examples the soap:Envelope is identical to the one above but is omitted for
clarity reasons.
...
Klok klok = new KlokClient();
...
DateTime dt = klok.getCurrentTime();
Request:
<soap:Body>
<rmi:request interface="Klok" methode="getCurrentTime" type="DateTime"/>
</soap:Body>
Response:
<soap:Body>
<rmi:response interface="Klok" method="getCurrentTime" type="DateTime">
<rmi:return>
<DateTime><Date y="2002" m="9" d="25"><Time h="14" m="31" s="24"></DateTime>
</rmi:return>
</rmi:response>
</soap:Body>
...
Session session = new SessionClient();
...
try
{
String sessionId = session.getSessionId();
}
catch(SoapExceptionTooManySessions ex)
{
System.out.println( "No session key available: " + ex.getMessage() );
}
catch(Exception ex)
{
System.err.println( "Unexpected exception: " + ex.getMessage() );
}
Request:
<soap:Body>
<rmi:request interface="Session" methode="getSessionId" type="String"/>
</soap:Body>
Response 1:
<soap:Body>
<rmi:response interface="Session" method="getSessionId" type="String">
<rmi:return>A34CZ8901q</rmi:return>
</rmi:response>
</soap:Body>
Response 2:
<soap:Body>
<rmi:response interface="Session" method="getSessionId" type="String">
<rmi:throws>
<SoapExceptionTooManySessions>Max number of sessions has been reached.</SoapExceptionTooManySessions>
</rmi:throws>
</rmi:response>
</soap:Body>
...
Transaction trans = new Transaction();
...
// code that fills trans
boolean succes = session.requestTransaction(sessionId, trans);
Request:
<soap:Body>
<rmi:request interface="Session" methode="requestTransaction" type="boolean">
<rmi:param name="sessionId" type="String">A34CZ8901q</rmi:param>
<rmi:param name="transaction" type="Transaction">asString() output of the Transaction object</rmi:param>
</rmi:request>
</soap:Body>
Response:
<soap:Body>
<rmi:response interface="Session" method="requestTransaction" type="boolean">
<rmi:return>true</rmi:return>
</rmi:response>
</soap:Body>
Soap.java
SoapException.java
Stringable.java
DateTime.java
Kalender.java
KalenderClient.java
Session.java
SessionClient.java
SoapExceptionTooManySessions.java
Transaction.java
Normally the above files, or at least the corresponding class and javadoc files, are published in a jar file.
Here is an example of a server side implementation: