Reputation: 368
I have clasess BankImpl, BankService, BankClient, BankServer and Bank interface. I want to instantiate that bank service so I can use it with my other webservices but dont know the correct way of doing it. I have something like this now:
Service service = Service.create(wsdlLocation, new
QName("http://bla/bla/bank", "BankService"));
Bank bank = service.getPort(new
QName("http://bla/bla/bank", "Bank"), Bank.class);
Is that the correct way or is there another, I saw on the net there is a ServiceFactory and some other techniques and all with their errors. I just want someone to tell me the correct way of instantiating the service class and using it. Thank you
Upvotes: 0
Views: 755
Reputation: 834
The way you are trying to create the client is correct, be carreful with the classes that you use, but the general idea is correct. This is a good tutorial for creating a web service and the client in that way.
Another way is using the wsconsume or wsimport tools. This are command line tools. Given a wsdl, they generate all the client side artifacts that let you call the web service.
Eclipse is integrated with this tools so you can create the client with the GUI. In File -> New -> Other -> Web Service Client is the GUI version of this tools. You have to provide the wsdl and some basic configuration (server runtime, web service runtime, etc).
Upvotes: 1