System.out.print("The last price for SUNW is " + stockQuote.getStockQuote("SUNW"));
}
public String getStockQuote(String tickerSymbol) throws Exception {
SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
SOAPConnection con = scFactory.createConnection();
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPHeader header = envelope.getHeader();
SOAPBody body = envelope.getBody();
header.detachNode();
Name bodyName = envelope.createName("getQuote", "n", "urn:xmethods-delayed-quotes");
SOAPBodyElement gltp = body.addBodyElement(bodyName);
Name name = envelope.createName("symbol");
SOAPElement symbol = gltp.addChildElement(name);
symbol.addTextNode(tickerSymbol);
URLEndpoint endpoint = new URLEndpoint("http://66.28.98.121:9090/soap");
SOAPMessage response = con.call(message, endpoint);
con.close();
SOAPPart sp = response.getSOAPPart();
SOAPEnvelope se = sp.getEnvelope();
SOAPBody sb = se.getBody();
Iterator it = sb.getChildElements();