DB2v.8 Web Services Tutorial

of 32
7 views
PDF
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Document Description
Invoking Web services from SQL Integrating relational data with Web services using DB2 Skill Level: Intermediate Tim Brown DB2 Universal Database Solutions Expert IBM James Magowan Web Services and Data Grids IBM 09 Jan 2003 Developing applications that access both Web services and database management systems can be an overwhelming task. It doesn't need to be. This tutorial demonstrates how to generate DB2 user-defined functions (UDFs) that provide access to Web services. The generated UDFs can
Document Share
Document Tags
Document Transcript
  Invoking Web services from SQL Integrating relational data with Web services using DB2 Skill Level: IntermediateTim BrownDB2 Universal Database Solutions ExpertIBMJames MagowanWeb Services and Data GridsIBM09 Jan 2003Developing applications that access both Web services and database managementsystems can be an overwhelming task. It doesn't need to be. This tutorialdemonstrates how to generate DB2 user-defined functions (UDFs) that provideaccess to Web services. The generated UDFs can be used in SQL statements tocombine relational data with dynamic data retrieved from a Web service. Severaldifferent examples are provided. Section 1. Before you start About this tutorial Web services provide access to distributed applications. They are increasingly usedto integrate information processing within and between enterprises. When buildingservice-based applications, Web services often need to be integrated with relationaldata. To accomplish this, applications must access both Web services and databasemanagement systems.The Web services consumer converts existing WSDL interfaces into DB2® table or Invoking Web services from SQLTrademarks © Copyright IBM Corporation 2003. All rights reserved.Page 1 of 32  scalar functions. Web service consumer User Defined Functions (UDFs) can enabledatabases to directly invoke Web services using SQL. By using SQL to access WebServices data, you save effort because you can manipulate the data within thecontext of an SQL statement.You might think using these Web service consumer UDFs in SQL statements couldbe time consuming or require advanced programming skills. This tutorial will showyou otherwise. It will guide you through the steps to:ã Enable your database for Web Service consumer UDFsã Create Web service consumer UDFs using WebSphere® StudioApplication Developer wizardã Create Web service consumer UDFs using the DB2 command lineAfter generating and deploying the UDFs, they can be used by application programsto combine relational data with dynamic data retrieved from the Web service.Examples are given to show how to use the UDFs in SQL statements. This tutorialassumes basic knowledge of Web services, DB2 SQL, and WebSphere StudioApplication Developer V5.1.1. If you are not familiar with Web services, or you coulduse a refresher, developerWorks  has an excellent introductory tutorial on Webservices (seeResources). Prerequisites To complete the steps in this tutorial, you'll need the following software installed andrunning:ã DB2 Universal Database V8.1 FixPack 4ã WebSphere Studio Application Developer V5.1.1. This is optional - youcan use the DB2 command line but Application Developer makes it mucheasier.A free trial version DB2 Universal Database® V8.1 is available from thedeveloperWorks download page.This tutorial has been revised from one srcinally created by Marcus Schneider andDan Wolfson (IBM Distinguished Engineer). Notices and trademarks Copyright, 2003 International Business Machines Corporation. All rights reserved. developerWorks® ibm.com/developerWorksInvoking Web services from SQLTrademarks © Copyright IBM Corporation 2003. All rights reserved.Page 2 of 32  IBM, DB2, DB2 Universal Database, DB2 Information Integrator, WebSphere andWebSphere MQ are trademarks or registered trademarks of IBM Corporation in theUnited States, other countries, or both.Other company, product, and service names may be trademarks or service marks ofothers. Section 2. Getting started Enable XML Extender DB2 Web service consumer user-defined functions have been available as standardsince Fix Pack 2 for DB2 v8. They are not, however, enabled by default and dorequire DB2 XML Extender functionality to be enabled.DB2 XML Extender allows XML documents to be stored intact and indexed in sidetables, or as a collection of relational tables. It uses an XML document format calledthe Document Access Definition (DAD) to define the mapping between XML andrelational data.If you have any problems with the following instructions, refer to the DB2 Webservices consumer documentation available fromResources. To enable XMLExtender execute the following commands from a DB2 command line:1. Connect to the database you want to enable: db2 connect to database_name 2. Enable the database for XML Extender: dxxadm enable_db database_name Issuing these commands against the sample database results in the followingoutput: DXXA002I Connecting to database SAMPLE .DXXA005I Enabling database SAMPLE . Please wait.DXXA006I The database SAMPLE was enabled successfully. Five system user-defined functions to handle SOAP are provided. These must beregistered by issuing the following command: ibm.com/developerWorks developerWorks® Invoking Web services from SQLTrademarks © Copyright IBM Corporation 2003. All rights reserved.Page 3 of 32  db2enable_soap_udf -n database_name -u username -p password  [-force] The -force attempts to drop any existing functions.To disable the SOAP UDFs, use the following command: db2disable_soap_udf -n database_name -u username -p password  The enable command copies the shared library containing the implementation of thesoap functions to your sqllib/function directory.To check that you enabled the database correctly, verify the following UDFs aredefined. From within the Control Center, go to Application Objects =>UserDefined Functions . This should list the following: Name Schema Specific Name Result Input Parameters SOAPHTTPV DB2XML SOAPHTTPVIVO VARCHAR (VARCHAR(),VARCHAR(),VARCHASOAPHTTPV DB2XML SOAPHTTPCIVO VARCHAR (VARCHAR(),VARCHAR(),CLOB())SOAPHTTPC DB2XML SOAPHTTPCICO CLOB (VARCHAR(),VARCHAR(),CLOB())SOAPHTTPC DB2XML SOAPHTTPVICO CLOB (VARCHAR(),VARCHAR(),VARCHASOAPHTTPCL DB2XML SOAPHTTPVICLO CLOB (VARCHAR(),VARCHAR(),VARCHA Also check to ensure db2soapudf.dll appears in your sqllib/function directory. Note: With Windows XP it may be necessary to drop the -u and -p options from thecommands.HTTP proxies are not currently supported for Web Service Consumer User DefinedFunctions. That can cause problems when invoking the Web service. Section 3. Create a UDF using the wizard Launch the wizard Before you create a Web service UDF, create a project for use with the Web serviceUDF. To create a new project: developerWorks® ibm.com/developerWorksInvoking Web services from SQLTrademarks © Copyright IBM Corporation 2003. All rights reserved.Page 4 of 32
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks
SAVE OUR EARTH

We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

More details...

Sign Now!

We are very appreciated for your Prompt Action!

x