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 ...

Get Java™ Web Services Unleashed 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.