Tutorial - Live Stock Quotes Using IP*Works! SOAP Component
This guide demonstrates how to Access a web service provided by
www.xmethods.net. To find the WSDL (service description) for this
service, you can download it at the following URL:
http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl .
This service expects one piece of input: a valid stock ticker symbol. It has
one output: a 20 minute delayed stock quote of the current price of the stock.
In this example, we will use MSFT, the symbol for Microsoft.
We will use the SOAP component included in the IP*Works! .NET Edition to
access the web service. The IP*Works! SOAP component implements a standard SOAP
client as specified in the SOAP 1.1 specification.
For this, we will need several pieces of information about the service to
continue. The Method URI, the Action URI, an endpoint URL, and a method name.
All of this information can be obtained from the service provider or from the
WSDL. This procedure is covered in separate document, "Understanding of WSDL".
You can contact support@nsoftware.com
if you would like more information.
For this particular service at xmethods.net, xmethods has been kind enough to
provide us with all the details we will need:
Method URI: urn:xmethods-delayed-quotes
Action URI: urn:xmethods-delayed-quotes#getQuote
Endpoint URL: http://66.28.98.121:9090/soap
Method: getQuote
All of this information can be provided to the SOAP component with obvious
properties:
Soap1.MethodURI = "urn:xmethods-delayed-quotes"
Soap1.ActionURI = "urn:xmethods-delayed-quotes/getQuote"
Soap1.URL = "http://66.28.98.121:9090/soap"
Soap1.Method = "getQuote"
We'll take this code and put it in a function, add the input data (MSFT) and
call the SendRequest method to send the actual soap packet to
the server.
Now we'll add a little GUI - a simple button to perform the Quote request
(cmdGet), an input box for a user to enter a symbol (tbSymbol), an output
box where the price will appear after the service returns it to the SOAP
component (tbOutput).
When the "Get Quote" button is clicked, we call the function that we have
defined, getStockQuote
. This function will return the value of the price of the stock and we will
output it to the output box.
Private Sub cmdGet_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmdGet.Click
tbOutput.Text += getStockQuote(tbSymbol.Text)
End Sub
We're finished! Below is the relevant source of this little demo.
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Function getStockQuote(ByVal symbol As String) As String
Soap1.MethodURI = "urn:xmethods-delayed-quotes"
Soap1.ActionURI = "urn:xmethods-delayed-quotes/getQuote"
Soap1.URL = "http://66.28.98.121:9090/soap"
Soap1.Method = "getQuote"
Soap1.AddParam("symbol", symbol)
Soap1.SendRequest()
WSDL_StockQuoteService_getQuote = Soap1.ReturnValue()
End Function
Private Sub cmdGet_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmdGet.Click
tbOutput.Text += getStockQuote(tbSymbol.Text)
End Sub
End Class
We appreciate your feedback. If you have any questions, comments, or
suggestions about this article please contact our support team at
kb@nsoftware.com.