SOAP and Web Services
DNS Service Discovery
15
An example of its usage is shown below:
// Create the oAsync notification object:
var myNotifications = {
// This method is called whenever a service is added:
addServices: function(services)
{
for (var i=0; i<services.length; i++) {
var str = "ADD: ";
str += services[i].name;
str += " in domain ";
str += services[i].domain;
console.println(str);
}
}
// This method is called whenever a service is removed:
removeServices: function(servces)
{
var str = "DEL: ";
str += services[i].name;
str += " in domain ";
str += services[i].domain;
console.println(str);
}
};
// Perform the service discovery:
SOAP.requestServices({
cType: "http",
oAsync: myNotifications,
aDomains: [ServiceDiscovery.local, ServiceDiscover.default]
});
Once a service has been discovered, it can be bound through the
SOAP
object’s
resolveService
method to a network address and port so that a connection can be
established. The
resolveService
method accepts the following parameters:
●
●
●
●
cType
: the DNS SRV service name (such as "http" or "ftp").
cDomain
: the domain in which the service is located.
cService
: the service name to be resolved.
oAsync
: a notification object used when the service is resolved. It implements a
resolve
method that accepts parameters
nStatus
(
0
if successful) and
oInfo
(used
if successful, contains a
serviceInfo
object). The
serviceInfo
object contains the
following properties:
–
target
: the IP address or DNS name of the machine providing the service.
–
port
: the port on the machine.
–
info
: an object with name/value pairs supplied by the service.
Acrobat JavaScript Scripting Guide
257