Accessing a Web Service

LANSA

Accessing a Web Service
Example 211 - Rating: advanced
The Things that Make Up this ExampleTo Execute this Example

This example demonstrates how the Java Service Manager might be used to access a web service. The web service accessed is the NASDAQ stock quotes system.

(This is an introductory XML web service example. For a detailed look at building XML web service clients refer to examples 214 and 215. For a detailed look at building XML web services refer to examples 216 and 217.)

In essence you provide the NASDAQ quote system with a list of stock codes (called symbols) and it gives you back up to the minute details of the stocks:



This type of exchange between unknown computer systems, using the Internet as the communications medium, is becoming increasingly common.

In this example various types of LANSA applications executing in different contexts (Web, 5250 green screen, MS-Windows and batch) use the JSM to get NASDAQ stock price quotes …



Structurally the SET components that make up this example interact like this:



where:
SET211QIs a common interface to the NASDAQ stock price query system
SET211WRequests stock symbols and presents the results on a web page
SET211GRequests stock symbols and presents the results on an iSeries 5250 “green screen”
S_211FMFRequests stock symbols and presents the results on a windows form
SET211SSimply submits SET211B to batch, passing it a list of up to 5 stock symbol names
SET211BExecutes in batch and uses SET211Q to access the NASDAQ system

Functions SET211W/G/S/B and form S_211FMF are simply different user interfaces to the function SET211Q. All JSM processing in this example is contained in function SET211Q.

Look at the source of function SET211Q in process SET_211 for detailed information about this example.

SET211G Requests stock symbols and presents the results on an iSeries 5250 green screen





Notes and Suggestions

On the way out of LANSA, we send Name-Value (NV) pairs because that is what the NASDAQ service expects. The NV pair information is stored in the working list #NAMEVALUE. Once the list has been filled with the correct information it is sent using the JSM_COMMAND Built In function.

NASDAQ expects the NV pairs formatted like this:
In the NAME columnIn the VALUE column
ModeStock
PageXML
Symbol<stock symbol>



In our example, if you don’t change any of the default stock symbols presented by the user interfaces, the working list #NAMEVALUE will contain exactly this when it is sent to the service:
In the NAME columnIn the VALUE column
ModeStock
PageXML
SymbolIBM
SymbolMSFT
SymbolSUNW
SymbolAAPL
SymbolCPQ



NASDAQ responds sending back data in XML format. It sends much more information than the one we display or print (depending on the user interface). We chose to show some of it. The data is received by LANSA, transformed using a style sheet and the information is mapped back into the function.

Using the style sheet, LANSA will map the values returned into #NASQUOTES working list.

This Example Also Demonstrates:
  • Batch Programming
Keywords
Example 211JSM
JSMWeb Service
InternetNASDAQ
BatchPrinting
XMLHTTP
Named Pairs