Java Reference
In-Depth Information
QName("http://www.packtpub.com/", "TicketWebService");
final Service service = Service.create(wsdlURL,
SERVICE_NAME);
final TicketWebService infoService =
service.getPort(TicketWebService.class);
logger.info("Got the Service: " + infoService);
infoService.bookSeat(seatId);
logger.info("Ticket Booked with JAX-WS Service");
final List<SeatDto> list = infoService.getSeats();
dumpSeatList(list);
}
private static void dumpSeatList(Collection<SeatDto>
list) {
logger.info("================= Available Ticket
List ================");
list.stream().forEach(seat ->
logger.info(seat.toString()));
}
}
The service WSDL URL and name are needed for retrieval of the Service object. Fin-
ally, the getPort method will return a proxy to your web service that can be used to test
two basic operations: booking a seat and checking from the Seat list if the seat has actu-
ally been reserved.
This small standalone class has shown how it is possible to use SOAP-based services
from the client-side perspective.
The most interesting part, however, is at the bottom of the Maven output, where the
Ticket list is dumped after booking one seat, as depicted in the following command
line:
apr 01, 2014 1:08:44 AM
com.packtpub.wflydevelopment.chapter7.webservice.TicketWebServiceTestApplication
Search WWH ::




Custom Search