Tuesday, May 14, 2013

Integrating Web Service with Datastage



Web services expose operations of custom functions accessible to applications through internet or intranet. Web services are interoperable, reusable and follow strict standards and protocols to be followed for accessing them.

SOAP (Simple Object Access Protocol) is a specification for exchanging information between application and Web Service. Web service request and response are encoded in XML format.

This blog is to provide step-by-step instruction on invoking a web service through Datastage.

At the high level, following are the steps to be followed.
  1. Identify and Save Web Service Definition 
  2. Import Web Service Definition 
  3. Configure Web Service Operation 
  4. Configure Web Service Request 
  5. Configure Web Service Response

Identify and Save Web Service Definition

Many web services are publicly available for free. In this example, let us try to access Country web service published through webservicex site.


WSDL definition is listed on the XML frame. 

If you are using Firefox,

Right click on WSDL definition frame
Select “This Frame” option from popup menu
Select “Save frame as” option to locally save the file






If you are using Internet Explorer

          Click on WSDL definition frame
          Select File Menu and Click Save As option to save the file locally

Import Web Service Definition

This step will help to import the WSDL file saved in previous step into Datastage

  • Login to Datastage Designer 
  • Select Web Service Function Definitions in “Import” menu.
   


  • It opens Web Services browser which lists all the definitions already available on the Datastage project
  •  Click on “Metadata Importer” option


  •  Click on “Open File” option and select the location of WSDL file saved earlier


  • Web service explorer will lists the available web service operations
  • Right click one of the service operation and select Import all operations

 Configure Web Service Operation

Next step is to create a Server Job to access “Country” Web Service through Web Services Client Stage.
  • Login to Datastage Designer and Create a new Server Job 
  • From Palette, Select Web Services Client from Real Time group 
  • Place a sequential file stage as output

  • Open Web Services Client stage properties
  • Click on “Select Web Service Operation”




  • Click on “Select Web Service Operation”
  • Select “GetCountries” option. This web services does not have any input argument to be passed and hence Web Services Client stage is used for data retrieval.


  • Select “GetCountries” option and click on “Select this item” link
If the Datastage server is running behind a proxy for internet access (as most of the site does), configure proxy settings in Proxy tab
  • Enable HTTP/HTTPS option
  • Supply user name and password for accessing internet 

  • Specify proxy host name (without http). If host name and port details are not known, its a general practice to contact Datastage Administrator to obtain such information. 
If Datastage sever and Datastage client machine are directed through same internet proxy, these details can be extracted using the steps below. However, this is not recommended and demonstrated here for test purpose only.


Open Control Panel, Internet Options.
Select LAN Settings from Connections tab




Open the URL specified in LAN settings on a web browser

Host name and port details are generally specified at the “return” statement in configuration script. Supply this information in Web Services Client stage.

NOTE:
  • This would work only when the server is already rightly configured for internet access through proxy 
  • Include the server details in Web Client Stage excluding the file name

Configure Web Service Request

Open Web Services Client stage, Output tab

Open Input Arguments tab
Click on “Load Arguments Information” button. This loads namespace definitions into canvas



Configure Web Service Response

Open Web Services Client stage, Output tab

Open Output Message tab
Click on “Load Arguments Information” button. This loads output namespace definitions into canvas



Open Columns tab and check whether output column is populated 


Save, Compile and Run the job


Output file should have contents similar to the following


References

IBM Web Services Pack Guide






17 comments:

  1. Good work. Clearly mentioned the steps. Thank you.

    ReplyDelete
  2. Hi anantha, Under Proxy settings, what is Host Name & Port Number. I am assuming Host Name is webservicex.net. Is this correct or please let me know where to get the Host Name & Port Number.
    Thank you

    ReplyDelete
  3. HI , I tried all the steps, but I am not getting data into output file. I am getting 0 records

    ReplyDelete
  4. Hey I am getting errors like

    Web_Services_Client_0,0: Failure during execution of operator logic.
    Web_Services_Client_0,0: Fatal Error: Fatal: ASCL-DSJNI-00005`:`TJClient::initialize: unable to create Java Virtual Machine; classpath = java/lib/wsclient.jar
    java/lib/axis.jar
    java/lib/commons-discovery.jar
    java/lib/commons-logging.jar
    java/lib/jaxrpc.jar
    java/lib/saaj.jar
    java/lib/wsdl4j.jar
    java/lib/wss4j-1.6.18.jar
    java/lib/xmlsec-1.4.2.jar

    node_node1: Player 1 terminated unexpectedly.

    main_program: APT_PMsectionLeader(1, node1), player 1 - Unexpected exit status 1.

    main_program: APT_PMsectionLeader(2, node2), player 1 - Unexpected exit status -1.

    main_program: Step execution finished with status = FAILED.

    Please let me know what is needed to get this job done

    Thank you in advance.

    ReplyDelete
    Replies
    1. Hi Avinash Kotina,

      Before Integrating WebService you need to configure .Please follow below instructions.

      Step 1: Setup User defined environment variables in Data Stage Administrator.
      DATASTAGE_JRE=C:\IBM\InformationServer\_jvm\jre
      DATASTAGE_JVM=bin\j9vm
      DSHOME=C: \IBM\InformationServer\Server\DSEngine

      Step 2: Add DSHOME path in System Environment path. i.e
      Right Click on My Computer --> Properties --> Advanced System Settings --> Environment Variables --> System Variables
      DSHOME= "C:\IBM\InformationServer\Server\DSEngine"

      Step 3: In Job Properties import environment variable
      Open job --> Job Properties --> Parameters --> Add Environment variable --> User Defind variables

      Select these 3 variables
      DATASTAGE_JRE
      DATASTAGE_JVM
      DSHOME

      Delete
    2. Hey Ram,

      Thank you man. Bit late but this was effective.
      Thanks for your information.

      Delete
  5. This comment has been removed by the author.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. تصميم المواقع أفضل الممارسات التي يقوم بها أصحاب الأعمال اليوم يمكنك الأن
    تصميم مواقع
    تصميم متجر الكتروني

    ReplyDelete