[jboss-user] [JBossWS] - Re: Single Client, Multiple Service Endpoints

elcapitan do-not-reply at jboss.com
Wed Dec 20 23:49:02 EST 2006


The closest thing I have found to a solution for this so far is to create different mapping files for each service, i.e. service1-mapping.xml, service2-mapping.xml, etc., and then use the JBoss-proprietary ServiceFactoryImpl class's method createService(URL wsdlDocumentLocation, QName serviceName, URL mappingLocation) to create services on the client side. (The standard javax.xml.rpc.ServiceFactory class doesn't provide a createService method that allows explicit specification of the mapping file.)

The client-side code, then, looks something like the following (this is really just a test, so please excuse the hacky and hard-coded nature of it):

// URLs locating important files.
  | URL watchListWSDL = null;
  | URL watchListMapping = null;
  | URL crawlerWSDL = null;
  | URL crawlerMapping = null;
  | try {
  | 	watchListWSDL = new URL("http://localhost:8080/crawler/WatchListManager?wsdl");
  | 	watchListMapping = (new File("src/META-INF/watchlist-mapping.xml")).toURL();
  | 	crawlerWSDL = new URL("http://localhost:8080/crawler/CrawlerManager?wsdl");
  | 	crawlerMapping = (new File("src/META-INF/crawler-mapping.xml")).toURL();
  | } catch (MalformedURLException e) {
  | 	e.printStackTrace();
  | }
  | 		
  | // Qualified names of the services.
  | QName watchListQName = new QName("http://servercontroller.application.server.webcrawler.thedistillery.com.au/jaws",
  | 	"WatchListManagerInterfaceService");
  | QName crawlerQName = new QName("http://servercontroller.application.server.webcrawler.thedistillery.com.au/jaws",
  | 	"CrawlerManagerInterfaceService");
  | 		
  | // Services (note that we use the org.jboss.ws.jaxrpc.ServiceFactoryImpl class)
  | ServiceFactoryImpl factory = null;
  | Service watchListService = null;	
  | Service crawlerService = null;
  | try {
  | 	factory = (ServiceFactoryImpl) ServiceFactory.newInstance(); 
  | 	watchListService = factory.createService(watchListWSDL, watchListQName, watchListMapping);
  | 	crawlerService = factory.createService(crawlerWSDL, crawlerQName, crawlerMapping);
  | } catch (ServiceException se) {
  | 	System.out.println("Couldn't create service");
  | }
  | 
  | WatchListManagerInterface wlm = null;
  | CrawlerManagerInterface cm = null;
  | try {
  | 	wlm = (WatchListManagerInterface) watchListService.getPort(WatchListManagerInterface.class);
  | 	cm = (CrawlerManagerInterface) crawlerService.getPort(CrawlerManagerInterface.class);
  | } catch (ServiceException e1) {
  | 	e1.printStackTrace();
  | }
  | 		
  | // Code that actually uses the services goes here.

This seems to work OK, but I haven't tested it fully and since the services share classes, I'm not sure that it will work out alright in the long run. Any feedback would be extremely welcome!

Thanks guys,

James

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995505#3995505

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995505



More information about the jboss-user mailing list