<TradingAdvertisement adType="client">
<searchKeywords>
TradingClientAd, c-interface
JavaRMI, c-interfaceName
RMITimeService, c-derivedFrom
Remote, c-clockResolution
seconds, c-serviceCost
free,
</searchKeywords>
<metadata>
<mustHave>
<mdata name="clockResolution" value="seconds"/>
</mustHave>
<reallyWant>
<mdata name="serviceCost" value="free"/>
</reallyWant>
</metadata>
<interface>
<JavaRMI name="RMITimeService">
<derivedFrom interfaceName="Remote"/>
<method name="getTime" returnType="String">
<parameter name="timeZone" type="String" direction="in"/>
<exception name="RemoteException"/>
</method>
</JavaRMI>
</interface>
</TradingAdvertisement>
</xml>
<TradingAdvertisement adType="service">
<searchKeywords>
TradingServiceAd, s-interface
JavaRMI, s-interfaceName
RMITimeService, s-derivedFrom
Remote, s-clockResolution
seconds, s-serviceCost
free,
</searchKeywords>
<metadata>
<mdata name="clockResolution"
value="seconds"/>
<mdata name="serviceCost"
value="free"/>
</metadata>
<interface>
<JavaRMI name="RMITimeService">
<derivedFrom interfaceName="Remote"/>
<method name="getTime" returnType="String">
<parameter name="timeZone" type="String" direction="in"/>
<exception name="RemoteException"/>
</method>
<connectPoint uri="rmi://dante/RMITimeServer"/>
</JavaRMI>
</interface>
</TradingAdvertisement>
As you can see from the DOCTYPE tag, the trading ads are governed by a DTD, which specifies the grammar of the ad, its tags and attributes. An ad has three main sections, the searchKeywords, the metadata, and the interface. The searchKeywords are a mechanism for exposing information about the ad to a web search engine crawler when the ad is embedded in an HTML document. The way the ad grammar is defined by the DTD embeds the data of the ad inside various ad-specific XML tags, except in the case of the searchKeywords. Since none of the ad-specific tags are part of the official HTML grammar they are ignored by HTML and its crawlers, and only the searchKeywords are picked up. (These keywords could perhaps be replicated in meta tags in the head section of an HTML page, but some web crawlers specifically avoid indexing pages using this information due to page spamming concerns). The metadata section allows arbitrary lists of name-value pairs, as well as some expression of the need or value of particular pieces of metadata. The interface section is where an operational interface is described, both in terms of its type and its location (via connectPoint tags - multiple locations are allowed). Currently only HTTP CGI and Java RMI type interfaces are supported by the trading ad DTD. CORBA IDL would be a natural addition. Also, the DTD in general is not set in stone, and may be modified to improve or add capability. How to handle DTD evolution for compatibility with fielded systems and ads is an open issue.
How does a client actually use the WebTrader? Below is a code snippet from a Java code example supplied with the WebTrader wherein a client uses the WebTrader to find a Internet-based time service that speaks Java RMI.
// Get a handle to the WebTrader
String traderURL = "rmi://dante/TraderJoe";
Trader trader = new Trader (traderURL);
...
// Use the trader to find a service for our needs
String ourURL = "http://dante/Trader/RMITimeClient.html";
TraderMatch matches = trader.getMatches (ourURL, 1); // only
get 1 match
....
// Link to the time server we got from the trader and get the time
ConnectPoint connectPoints[] = matches[0].getConnectPoints();
String url = connectPoints[0].getUri();
RMITimeService rmiTime = (RMITimeService) Naming.lookup (url);
String time = rmiTime.getTime (timezone);
First, a link to a WebTrader is established. The WebTrader is implemented as a Java server with an RMI interface, and dante is the hostname where the trader we are after is running. Next, we ask the trader to find matches for the client trading ad embedded in the webpage RMITimeClient.html, also served from dante. Note that the client ad in this webpage is the same client ad used as an example in The Trading Advertisement section. Finally, the client processes the results from the WebTrader to actually connect to the service found and get the time.
How does a service actually use the WebTrader? The service's responsibility, beyond advertising itself via a trading ad in a webpage that gets indexed by the desired search engine or search engines, is merely to fulfill the promise of its ad. In this example we show the the Internet time service companion to the client above.
// The getTime() implementation
public String getTime (String timezone) throws RemoteException
{
TimeZone tz = null;
Calendar cal;
if (timezone != null) tz = TimeZone.getTimeZone
(timezone);
if (tz == null) tz = TimeZone.getDefault();
cal = Calendar.getInstance (tz);
return DateFormat.getDateTimeInstance().format(cal.getTime());
}
// Registering the time service
...
RMITimeServer server = new RMITimeServer();
Naming.rebind ("RMITimeServer", server);
...
So, here we have the implementation of the getTime() method as advertised by the service, and the registering of the service under the name "RMITimeServer" as specified in the connectPoint tag of the service's ad.
© Copyright 1998 Object Services and Consulting, Inc. Permission is granted to copy this document provided this copyright statement is retained in all copies. Disclaimer: OBJS does not warrant the accuracy or completeness of the information in this survey.
Last revised: September 30, 1998. Send comments to Tom Bannon.