HomeDigital EditionSys-Con RadioSearch Web Services Cd
B2B Beginning WS Business Process Management Case Studies Content Management Distributing Computing e-Business Electronic Data Interchange Enterprise Industry Insight Integration Interviews Java & Web Services .NET Portal Product Reviews Scalability & Performance Security SOAP Source Code UDDI Wireless WS Standards WS Tips & Techniques WSDL WS Editorials XML

Concurrently Accessing Multiple Web Service Instances, by Joe Verzulli
WSJ Vol 02 Issue 03 - pg.63

	

Listing 1 IBookstore multiBookstore; String urls = {"http://host1.com:8080/soap/servlet/rpcrouter", "http://host2.com:8080/soap/servlet/rpcrouter"} multiBookstore = (IBookstore) MultiServiceProxy.newInstance( Bookstore_ServiceProxy.class, urls, listener); multiBookstore.getPrice("OOSC2"); Listing 2 class SampleIncrementalListener implements IIncrementalServiceListener { public void result(ServiceResultEvent r) { System.out.println("Got result " + r.getValue() + " from Web service " + "at URL " + r.getURL()); } } . . . // The following code is in the client that will // contact multiple web services. IIncrementalServiceListener listener = new SampleIncrementalListener(); multiBookstore = (IBookstore) MultiServiceProxy.newInstance( Bookstore_ServiceProxy.class, urls, listener); multiBookstore.getPrice("OOSC2"); System.out.println("Back from " + "multiBookstore.getPrice()"); Listing 3 public static synchronized Object newInstance( Class webServiceProxyClass, String urls[], IServiceListener listeners[]) { return Proxy.newProxyInstance( webServiceProxyClass.getClassLoader(), webServiceProxyClass.getInterfaces(), new MultiServiceProxy( webServiceProxyClass, urls, listeners)); }

Additional Code For This Article (VerzulliWSJ0203.zip)