use of com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor in project quickstart by wildfly.
the class WSATSimpleServletClient method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
/*
* Add client handler chain
*/
BindingProvider bindingProvider = (BindingProvider) client;
@SuppressWarnings("rawtypes") List<Handler> handlers = new ArrayList<>(1);
handlers.add(new JaxWSHeaderContextProcessor());
bindingProvider.getBinding().setHandlerChain(handlers);
/*
* Lookup the DNS name of the server from the environment and set the endpoint address on the client.
*/
String openshift = System.getenv("OPENSHIFT_APP_DNS");
if (openshift != null) {
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://" + openshift + "/RestaurantServiceAT");
}
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
out.write("<h1>Quickstart: This example demonstrates the deployment of a WS-AT (WS-AtomicTransaction) enabled JAX-WS Web service bundled in a war archive for deployment to *Red Hat JBoss Enterprise Application Platform*.</h1>");
System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
UserTransaction ut = UserTransactionFactory.userTransaction();
try {
System.out.println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
ut.begin();
System.out.println("[CLIENT] invoking makeBooking() on WS");
client.makeBooking();
System.out.println("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
ut.commit();
out.write("<p><b>Transaction succeeded!</b></p>");
} catch (Exception e) {
e.printStackTrace();
out.write("<p><b>Transaction failed with the following error:</b></p>");
out.write("<p><blockquote>");
out.write(e.toString());
out.write("</blockquote></p>");
} finally {
rollbackIfActive(ut);
client.reset();
out.write("<p><i>Go to your JBoss EAP Server console or log to see the detailed result of the transaction.</i></p>");
}
}
Aggregations