The "cxf" frontend to the JAX-WS code generator (-fe cxf) now generates code that is a bit more "Java7" friendly as the return type of the getPort(...) calls is a sub-interface of the SEI that also implements AutoCloseable, BindingProvider, and Client. Code that used to look like:
(AddNumbersPortType port = service.getAddNumbersPort();
((BindingProvider)port).getRequestContext()
.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
port.addNumbers3(-1, 2);
((Closeable)port).close(); |
can be replaced with:
try (AddNumbersPortTypeProxy port = service.getAddNumbersPort()) {
port.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
port.addNumbers3(-1, 2);
} |