Sample code illustrates how to use the Java Client library
classes and methods to connect to the system and print the product
version number.
- BanterServerWebService_ServiceLocator bnsLocator
= new BanterServerWebService_ServiceLocator();
- java.net.URL bnsURL;
- try {
- bnsURL = new java.net.URL ("http://localhost:18087");
- } catch (java.net.MalformedURLException
e) {
- // Error handling
- }
- BanterServerWebServicePortType bnsServer
= getBanterServerWebService (bnsURL);
- BanterServerWebService_BindingStub bnsServerStub
= (BanterServerWebService_BindingStub)bnsServer;
- bnsServerStub.setUsername ("");
- bnsServerStub.setPassword ("");
- try {
- com.banter.bns.Version bnsVersion = bnsServer.validateConnection();
- System.out.println ("Server version = "
+ bnsVersion.getVerMajor() + "." + bnsVersion.getVerMinor());
- } catch (java.rmi.RemoteException e) {
- StringBuffer errDescription;
- int errNumber = BnsErrorLookup.getErrorDescription
(e, errDescription);
- // Error handling
- } catch (Exception e) {
- // Error handling
- }
The purpose of each section of the preceding
code is shown in the following list, by line numbers:
- 1
- Allocates a locator (com.banter.bns.BanterServerWebService_ServiceLocator)
object.
- 4
- Allocates a URL (java.net.URL) object, given a
string URL.
- 5-7
- Error handling for the URL creation.
- 8
- Retrieves a reference to a BanterServerWebServicePortType.
- 9-11
- For future use. Sets the credential for connecting
to the Listener virtual directory, by downcasting the port type to
a binding stub.
- 14
- Calls the server method validateConnection.
- 15
- Prints the product version number.
- 16-22
- Error handling for the method validateConnection.