Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Consuming web services over SOAP/HTTP in TXSeries applications

Ramesh Belavadi (rbelavad@in.ibm.com), Staff Software Engineer, IBM
Ramesh Belavadi
Ramesh Belavadi has more than 9 years of experience at IBM. He was working as a TXSeries L3 support Engineer before he joined XMS Team as Performance and Test Engineer.
Gururaja Manjunath (nmgururaj@in.ibm.com), Staff Software Engineer, IBM
Gururaja Manjunath
Gururaja Manjunath has more than 9 years of experience at IBM. He has mainly worked on Linux device drivers and TXSeries Encina and TXSeries CICS.
Shyam Prakash (pshyam@in.ibm.com), IT Product Specialist-TXSeries Specialist, IBM
Shyam Prakash
Shyam Prakash has more than 9 years of experience at IBM. He has a vast experience in TXSeries, AIX and Customer Engagements.

Summary:  This article provides an introduction to consuming web services over SOAP/HTTP in TXseries applications. It illustrates this with an example using Axis2/C and web services on WebSphere Application Server.

Date:  14 May 2010
Level:  Intermediate PDF:  A4 and Letter (394KB | 13 pages)Get Adobe® Reader®

Activity:  6592 views
Comments:  

Introduction

In this article we intend to show how web services based on SOAP/HTTP can be consumed in the TXSeries applications which are written in C and C++ language. This is illustrated in a step by step approach using examples.

Web services expect the requests to be a SOAP message. Hence TXSeries applications that need to consume Web Services will need a SOAP message translator to translate C, C++ function calls to SOAP messages. In the examples provided Apache Axis2/C will do this translation, to call a web service deployed in WebSphere Application Server.


Apache Axis2/C

Apache Axis2/C is a web services engine implemented in C programming language. It can be used to create web services and consume web services. In this article we are using Axis2/C as a web service client.


TXSeries for Multiplatforms

TXSeries for Multiplatforms is a transaction manager used by enterprises to process transactions. The TXSeries applications are designed in C, C++, Cobol, PL/1 languages. The transaction manager runs on multiple platforms including Windows, Solaris, AIX HP-UX and HP-Itanium.


Consuming web services in TXSeries Application

Within the J2EE environment many vendors provide their services to other application developers as web services. By integrating them with TXSeries, a rich application can be designed. Typical architecture of TXSeries application consuming web service is shown below in figure 1.


Figure 1. Architecture of TXSeries Application consuming web services
Architecture of TXSeries Application consuming web services

The steps for creating a simple TXSeries application that consumes web services are:

  1. Install and configure the required products.
  2. Obtain the WSDL file and create the stubs.
  3. Typical application code flow.
  4. Create a TXSeries region and configure the stanzas.
  5. Develop the TXSeries application.
  6. Compiling the application.
  7. Running the application.

1. Install and configure the pre-requisites

On a Windows machine install and configure Axis, Axis2/C and TXSeries for Multiplatforms for windows.

Install Axis 1.5.1 and save it in the following directory: C:\axis2-1.5.1.

Install Axis2/C and save it in the following directory: C:\axis2c1.5.

After the installation, set the environment variable AXIS2_HOME to C:\axis2-1.5.1 within the WSDL2C.bat file located in C:\axis2c1.5\bin\tools\wsdl2c.

The WSDL2C.bat file contains the following:


WSDL2C.bat

set AXIS2_HOME=C:\axis2-1.5.1
setlocal EnableDelayedExpansion
set AXIS2_CLASSPATH=%AXIS2_HOME%
FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set AXIS2_CLASSPATH=!AXIS2_CLASSPATH!;%%c;

Java -classpath %AXIS2_CLASSPATH% org.apache.axis2.wsdl.WSDL2C %*

2.Obtaining WSDL file and creating stubs

Most often web services will have a WSDL file associated with it. The WSDL file describes the messages that a client should send and receive. It also describes where the service resides and how it can be invoked. WSDL uses XML for this specification. To call the web service in C and C++ client applications, the clients stubcodes are generated from the WSDL file. This is accomplished by using a tool called WSDL2C provided by Axis2/C.

Obtaining the WSDL file

Retrieve the WSDL file from the service provider for the required service. If you know the endpoint of the service, the WSDL file can be obtained by appending ?wsdl to the service end-point.

Here we list down the steps involved in generating the stub code for a web service named "QuoteService".

Let us consider that "QuoteService" example takes the "company name" as the input and gives the "stock quote price" of that company as the output. This QuoteService is deployed on a Websphere Application Server on a host named "xmspamdwin64" and listening on port 9080. The service endpoint for "QuoteService" is http://xmspamdwin64:9080/StockQuoteproj/services/QuoteService.

The WSDL file is obtained by appending ?wsdl to service endpoint as shown below http://xmspamdwin64:9080/StockQuoteproj/services/QuoteService?wsdl.

Generating stubs from WSDL file

The WSDL2C.bat tool provided with the Axis2/C is used to generate client stub files. In our example the client stub for the "QuoteService.wsdl" is generated using either of the following command.

./WSDL2C.bat  -uri QuoteService.wsdl -d adb -u 
or
./WSDL2C.bat -uri http://xmspamdwin64:9080/StockQuoteProj/services/QuoteService?wsdl
 -d adb -u

The definitions of the options are:

-d  adb	  Choose adb (axis data binding)
-u        Unpacks the databinding classes

It generates following stub files in src directory by default:

adb_GetQuote.c  
adb_GetQuoteResponse.c  
adb_GetQuote.h  
adb_GetQuoteResponse.h  
axis2_stub_QuoteServiceService.h
axis2_stub_QuoteServiceService.c

Now we have generated the required client stub code to access the web service.

3. Typical application code flow

The TXSeries application should call the sequence of functions generated from the stub code to avail the web service. The stub functions called in the provided TXSeries example to avail the "QuoteService" are explained using the following diagram


Figure 2. Application code flow
Application code flow

4. Create TXSeries region and configure the stanzas

To create the TXSeries region and add the resources entries to the stanzas using the following commands:

cicscp -v create region region_name
cicsadd  -c td -r <region_name> TRAN1 ProgName="PROG1"
cicsadd  -c pd -r <region_name> PROG1 PathName="StockCheck.dll"
cicsadd  -c pd -r <region_name>  MAP3 ProgType=map PathName="map3.map

5. Developing the TXSeries application

In this section we explain the important steps involved in developing a TXSeries application to consume a web service using Axis2/c routines. The complete source code of the example is also provided for the reference.

Generate Map file for 3270 clients.

Create the BMS (quote.bms) file and headerfile (map3.h) using the CICSSDA tool. For more details on how to create BMS file please refer TXSeries for Multiplatforms 7.1 programming guide. Convert the BMS file to map file (map3.map) using the following command

cicsmap quote.bms

Copy the file map3.map to the following directory: C:/var/cics_regions/region_name/maps/prime

Axis2/C Initialization routines

Call the following Axis2/C routines as part of the initialization. The usage of these routines are explained in section 3.

axutil_env_create_all()
axis2_stub_create_QuoteServiceService()
adb_GetQuote_create()

Get the Input from 3270 Terminal

The following code segments illustrate how to get the input from the 3270 terminal using maps.

/* Send the MAP file 3270 to get company code and customers selection 
  from the user*/

sprintf(map3.map3o.statuso,"Enter Company Code");
EXEC CICS SEND MAP("MAP3") MAPSET("MAP3")
FREEKB ERASE RESP(rcode);
if(rcode != DFHRESP(NORMAL))
EXEC CICS ABEND ABCODE("SERR");

memset(&map3.map3i.cmpnamei,0,4);
memset(&map3.map3i.confi,0, 1);

/* Receive the MAP file with company code and the selection */

EXEC CICS RECEIVE MAP("MAP3") MAPSET("MAP3") RESP(rcode);
if(rcode != DFHRESP(NORMAL))
EXEC CICS ABEND ABCODE("RERR");
 

Invoke the web service from TXSeries.

/* Making request to web service */
stock_res = axis2_stub_op_QuoteServiceService_GetQuote(stub, env, stock_in);
 

Sending the result to the 3270 terminal

  /* extracting the returned value */
res_val = adb_GetQuoteResponse_get_GetQuoteReturn(stock_res, env);

fprintf(stderr, "result = %d\n", res_val);

sprintf(map3.map3o.quoteo,"%d",res_val);

sprintf(map3.map3o.statuso,"Transaction Ended");
EXEC CICS SEND MAP("MAP3") MAPSET("MAP3")
FREEKB ERASE RESP(rcode);
if(rcode != DFHRESP(NORMAL))
EXEC CICS ABEND ABCODE("SERR");
}
EXEC CICS RETURN; 

6. Compiling the application

Compile and link the TXSeries application with Axis2/C libraries by referring the commands provided in the cics_comp.bat file provided with the example code.

7. Executing the application

When the TXSeries transaction TRAN1 is executed on a 3270, the following screen shown in figure 3 is displaced. The company name for which the quote price is required and should be entered followed by a confirmation.


Figure 3. Executing the application launch screen
Executing the application           launch screen

On success, the quote price is displayed as shown in figure 4.


Figure 4. Success message
Success message

On failure, the following message is displayed as displayed in figure 5 below.


Figure 5. Failed message
Failed message

Limitations

The developer should be aware of the web service endpoint before implementing the solution.

Dynamic lookup of web service is not possible with this approach.

Error handling and security aspects are not covered in this article.

This solution is applicable only to C, C++ TXSeries application.

Advantage

Quick solution with the existing technologies with minimum development time.



Download

DescriptionNameSizeDownload method
A TXSeries application for this articleexample.zip4KBHTTP

Information about download methods


Resources

Learn

Get products and technologies

Discuss

About the authors

Ramesh Belavadi

Ramesh Belavadi has more than 9 years of experience at IBM. He was working as a TXSeries L3 support Engineer before he joined XMS Team as Performance and Test Engineer.

Gururaja Manjunath

Gururaja Manjunath has more than 9 years of experience at IBM. He has mainly worked on Linux device drivers and TXSeries Encina and TXSeries CICS.

Shyam Prakash

Shyam Prakash has more than 9 years of experience at IBM. He has a vast experience in TXSeries, AIX and Customer Engagements.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and web services
ArticleID=489080
ArticleTitle=Consuming web services over SOAP/HTTP in TXSeries applications
publish-date=05142010
author1-email=rbelavad@in.ibm.com
author1-email-cc=
author2-email=nmgururaj@in.ibm.com
author2-email-cc=
author3-email=pshyam@in.ibm.com
author3-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers