Developing a web service client

As we mentioned earlier, executable code needs to be generated from a web service's WSDL. A web service client will then invoke this executable code to access the web service.

The Java Development Kit (JDK) includes a utility to generate Java code from a WSDL. The name of the utility is wsimport. It can be found under $JAVA_HOME/bin. The only required argument for wsimport is the URL of the WSDL corresponding to the web service, for example:

wsimport http://localhost:8080/calculatorservice/CalculatorService?wsdl

The preceding command will generate a number of compiled Java classes that allow client applications to access our web service:

  • Add.class
  • AddResponse.class
  • Calculator.class
  • CalculatorService.class ...

Get Java EE 8 Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.