O'Reilly logo

Java™ Web Services Unleashed by Mark Wutka, Joseph Weber, Arthur Ryman, K. Scott Morrison, Benoît Marchal, Matthias Kloppmann, Steven Haines, Darren Govoni, Francisco Curbera, Frank Cohen, Robert Brunner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Test Client

Because the StockTrading class is available as a SOAP object, you have many ways to call it. Listing 21.10 shows an example client that logs in, issues a buy and a put, and then logs out.

Listing 21.10. Source Code for StockClient.java
 import java.util.*; import java.io.*; import java.net.*; import jwsunleashed.trading.ejb.TradeResult; import jwsunleashed.trading.TradingException; import org.apache.soap.*; import org.apache.soap.encoding.*; import org.apache.soap.encoding.soapenc.*; import org.apache.soap.rpc.*; import org.apache.soap.util.xml.*; public class StockClient { public static void main(String[] args) { try { URL url = new URL("http://localhost:8000/soap/servlet/rpcrouter"); // Create a new call for logging in Call call ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required