In my previous article (Learning Tools), I showed you how to download the Web Developer Express tool that you can use for web enabling. In this article, I will guide you through the steps for creating a simple ASP.NET example that can be used to Web-enable your NonStop application.
1. Build the Web Form (5 minutes)
A Simple ASP.NET Application
For this tutorial, I am using a very simple “logon” example to demonstrate how an ASP.NET application can interface to a simple NonStop server. This is what the user interface looks like.
Simple ASP.NET page (1 minute video)
The rest of this article focuses on some of the steps needed to create such an ASP.NET application to communicate with a NonStop application using SOAP/AM.
Create an ASP.NET Web Application
First, you will need to start Visual Web Express and create a new project.
After Visual Web Developer (VWD) is loaded:
- Click on “New Project”
- Click “ASP.NET Web Application”
- Type in project name (I used “SimpleLogon” in this screen capture)
Create an ASP.NET Form
Form is the user interface part of ASP.NET. For our demo, we are going to build a very simple ASP.NET form that captures the user input and calls the SOAP/AM Web Service on the NonStop.
Creating a simple ASP.NET Form (3 minute video)
2. Set up communication between the Web and Server (5 minutes)
Make sure you have the WSDL
As I pointed out in my “SOA 101” PPT presentation, WSDL (Web Service Description Language) is the blueprint of how a published Web Service can be accessed. A WSDL is usually generated by the Web Service tool on the platform, and doesn’t require any manual coding.
If you use SOAP/AM Server on the NonStop platform, you can generate the WSDL very easily by using the SOAP/AM Control Panel. Here is a video clip of how a NonStop program can be exposed as a Web Service by using SOAP/AM to create a WSDL. How to create a WSDL using SOAP/AM (3 minute video)
Importing the WSDL
Now that you have the WSDL ready, you will be able to add that as a “reference” to your project. That means your application can now “call” that server simply by using that reference name. Your program doesn’t know or care where that server resides, because the Web Service Interface makes it all transparent, which is exactly the beauty of this technology.
There are two ways to add the WSDL as a reference to be used by your program: Web Reference or Service Reference. For most practical purposes, they serve the same function, but if you are really interested in their technical differences, check out this Microsoft forum discussion.
I suggest that you use Web Reference when communicating with the NonStop. Here is a short video of what is involved in adding this web reference to your .NET project.
How to add a web reference (2 minute video)
Using the Reference
Once the reference is created, your application can then use it to call the Web service and pass it the necessary input parameters (as required by the request IPM) and retrieve the reply parameters (as returned in the reply IPM). Of course, before you do that, your application will need to go through the standard housekeeping activities common in all programs.
When the “Logon” button is clicked, the program branches to the “clicked” event routine to execute the code, which is explained below.
Here are the steps performed by the code behind this ASP.NET form:
- Create/declare local variables that map to the:
- Web Service
- Populate the Request (input) parameters by:
- getting them from the user input (as we do for the 3 input fields in our case); or
- populating them programmatically (e.g., we could have hidden the request_code “101” field from the user)
- Call the Web Service by:
- invoking the METHOD (logon) in the Web service (logonClient)
- including the input parameters (logonReq structure)
- Extract the needed output from the returned reply (logonReply)
- In our case, we are populating the screen fields (Reply Code and Reply Detail) with the returned parameters (reply_code and status_msg)
- Note that the reply actually has another returned parameter (status_code) that we did not use
So that’s it! That’s how simple it is for an ASP.NET or Windows .NET application to communicate to the NonStop using Web Service. Think about all the things that you DON’T have to do by using Web Service, like:
- trying to debate what protocols to use (HTTP and SOAP are standard)
- encryption (HTTPS is built-in)
- worrying about data mapping issues (XML and WSDL take care of that)
- creating code to handle protocol and error recovery (.NET generates all the necessary proxies for you)
And using SOAP/AM on the NonStop makes it so easy to “Web service-enable” your applications.
The best way to learn something is by doing. So I would suggest that you:
- Get some hands-on experience with Visual Web Developer by using some simple samples and resources available on http://www.asp.net
- Pick a simple Web Service (WSDL) on the Internet to work with, such as the weather services available from Cdyne
- Contact TIC for an evaluation copy of SOAP/AM Server and see it how it works on your NonStop system!
Next blog topic: Web Application Security
In my next blog, I will discuss important security information that you need to know to prevent your Web application or your Web-enabled NonStop programs from being compromised by external or internal hackers.
Do you find this tutorial blog helpful? Let us know what you think, and how we can make it even better. Don’t forget, you can subscribe to our blogs (top right-hand corner of the home page) to get automatic email notification when a new blog is available.
Phil Ly is the president and founder of TIC Software, a New York-based company specializing in software and services that integrate NonStop with the latest technologies, including Web Services, .NET and Java. Prior to founding TIC in 1983, Phil worked for Tandem Computer in technical support and software development.