Create a Web Service Client with JAX-WS
import com.javadb.ws.example.JavadbWebService;
import com.javadb.ws.example.JavadbWebServiceService;
public class Main {
public void callWebService() {
/* Note, the JavadbWebServiceService class has two constructors.
* The default one that we use here uses the wsdl-location that was
* specified at the time of the generation of the client classes,
* i.e. localhost. If the service is deployed at
* another location you need to use the constructor:
* public JavadbWebServiceService(URL wsdlLocation, QName serviceName)
*/
JavadbWebServiceService service = new JavadbWebServiceService();
JavadbWebService port = service.getJavadbWebServicePort();
String currentTime = port.getTime();
System.out.println("Current time is: " + currentTime);
}
public static void main(String[] args) {
new Main().callWebService();
}
}
Note that you need the genereated classes and the jax-ws libraries in the classpath when you compile and run the above class.
That is easiest done by pointing them out in your project properties in the IDE.
The output looks something like this:
Current time is: 15:54
0 comments: