The discovery package

The org.sblim.cimclient.discovery package offers high-level discovery functions for WBEM services. The design point behind it was to provide an API that is protocol agnostic and hides the nasty details of the discovery protocol and the advertisement format.

With the following code snippet you can discover all WBEM services using the SLP DA "da.foo.net":

String[] directoryAgents = new String[] {"da.foo.net"};
Discoverer discoverer = DiscovererFactory.getDiscoverer(DiscovererFactory.SLP);
WBEMServiceAdvertisement[] advertisements = discoverer.findWbemServices(directoryAgents);

The factory pattern allows support for discovery protocols other than SLP in the future. However, SLP is the only supported one today. The WBEMServiceAdvertisement interface provides the means to easily retrieve all the information from the WBEM template:

String url = advertisements[0].getServiceUrl();
String id = advertisements[0].getServiceId();
String[] ns = advertisements[0].getInteropNamespaces();
String name = advertisements[0].getAttribute(WBEMServiceAdvertisement.SERVICE_HI_NAME);

You may also create a WBEMClient directly from the WBEMServiceAdvertisement:

Subject subject = new Subject(); // in real life you would need real credentials ... of course
WBEMClient client = advertisements[0].createClient(subject, Locale.getAvailableLocales());

Last but not least we have the AdvertisementCatalog class. It helps managing the discovered advertisements by addressing common issues: