Developing an app using Web Services, DB2, and.net

Similar documents
Developing DB2 CLR Procedures in VS.NET

Developing DB2 CLR Procedures in VS.NET

An Introduction to Application Development in. Microsoft Visual Studio.NET

DB2 Stored Procedure and UDF Support in Rational Application Developer V6.01

In this lab, you will build and execute a simple message flow. A message flow is like a program but is developed using a visual paradigm.

Fastrack to federated replication

Creating a SQL Service with IBM WebSphere Portlet Factory. Introduction to creating services from a relational database

Introduction to IBM Rational HATS For IBM System i (5250)

Creating a REST API which exposes an existing SOAP Service with IBM API Management

Introduction to IBM Data Studio, Part 1: Get started with IBM Data Studio, Version and Eclipse

Introduction to IBM Data Studio, Part 1: Get started with IBM Data Studio, Version and Eclipse

Using IBM Rational Business Developer wizards to create a Web application

.NET and DB2 united with IBM DB2.NET Data Provider Objectives :.NET ADO.NET DB2 and ADO.NET DB2 - ADO.NET applications

Policy Manager for IBM WebSphere DataPower 7.2: Configuration Guide

TECHNICAL NOTE HOW TO USE WEB SERVICES. Document: Kalipso_TechDocs_Web_Services. Revision: 1.0. Kalipso version:

edocs Home > BEA AquaLogic Service Bus 3.0 Documentation > Accessing ALDSP Data Services Through ALSB

Including Dynamic Images in Your Report

IBM Enterprise Modernization for System z: Wrap existing COBOL programs as Web Services with IBM Rational Developer for System z

Developing WML applications using PHP

RSA NetWitness Logs. IBM WebSphere DataPower. Event Source Log Configuration Guide. Last Modified: Friday, January 5, 2018

Tootomatic with Java 2 v1.4.2_05, and a Self-test feature

Using ILOG JRules in WebSphere Integration Developer

Creating a REST API which exposes an existing SOAP Service with IBM API Management

Getting Started with the Bullhorn SOAP API and C#/.NET

Using the vrealize Orchestrator Operations Client. vrealize Orchestrator 7.5

ARCAD 5250 Emulator for WDSc and Eclipse. Tutorial

Healthcare Database Connector

Form into function. Getting prepared. Tutorial. Paul Jasper

DB2 Development in.net Environment

Rapid SQL 7.5 Evaluation Guide. Published: September 28, 2007

Tutorial. Unit: Interactive Forms Integration into Web Dynpro for Java Topic: Dynamically generated forms

IBM Integration Bus v9.0 Application Development I: Course Content By Yuvaraj C Panneerselvam

Import SEVIS Information from the Department of Homeland Security Trigger:

Using Smartphone devices with IBM WebSphere Portlet Factory

ARCAD 5250 Emulator for RDi and Eclipse. Tutorial

How to import a WSDL Data Source and Prepare it for Use in Framework Manager

ZOS15P1 - Rational Business Developper : Comment développer rapidement une application zos/db2 sans connaissance Cobol avec EGL et RBD

Creating Classic Planning Applications in Oracle Hyperion Planning, Fusion Edition

DB2 for IBM iseries Platform Extended with Enhanced Tools

WinForms Charts How to Invoke the Chart Wizard at Runtime

Introduction to Web Development with Microsoft Visual Studio 2010

Visual Composer for NetWeaver CE: Getting Started with a Typical Workflow

Embarcadero Rapid SQL

Embarcadero Change Manager 5.1 Installation Guide

Embarcadero Rapid SQL

Instructions for writing Web Services using Microsoft.NET:

ADO.NET 2.0. database programming with

Lab: Relational Universe Create Predefined Filters

Working with Metadata in ArcGIS

WebSphere Lab Jam Connectivity WebSphere Message Broker. Lab Exercises

Introduction to using Visual Studio 2010 to build data-aware applications

How to use data sources with databases (part 1)

Chat Starter Edition Administration Guide

Contents 1. Table of Contents. Report Server (Home Page) Installation. Manage Reports DevExpress Inc.

Visual Studio 2010 Xml Schema Explorer Tutorial

Enterprise Generation Language (EGL) for IBM i operating system Create a web application using EGL and the Data Access Application Wizard

ADF Mobile Code Corner

IBM WebSphere Message Broker with Rules and Formatter Extension for z/os, Version 6.0

Composite Application Tutorial I: NSF Components

IBM Integration Bus v9.0 System Administration: Course Content By Yuvaraj C Panneerselvam

IBM Rational Business Developer (RBD) is a development environment that

Enterprise Integration

Business Intelligence Exchange (BIX)

Tivoli Common Reporting V Cognos report in a Tivoli Integrated Portal dashboard

IBM WebSphere Lombardi Edition 7.2 Business Process Management Workshop

Unified Task List Developer Pack

How to Generating DB Specification from Database> Written Date : January 20, 2016

IBM. IBM WebSphere Business Modeler Advanced V6.0.2 Business Analysis and Design

Introduction to Web Development with Microsoft Visual Studio 2010

Register ME. Administrator's Guide

DOWNLOAD OR READ : USING MICROSOFT REPORT BUILDER A MICROSOFT OFFICE REPORT AUTHORING ENVIRONMENT FOR SQL SERVER AND OTHER DATA PDF EBOOK EPUB MOBI

IBM Rational Application Developer for WebSphere Software, Version 7.0

Getting Started with the Bullhorn SOAP API and Java

A SharePoint Developer Introduction. Hands-On Lab. Lab Manual HOL5 Using Client OM and REST from.net App C#

Managing Your Database Using Oracle SQL Developer

How To Develop a Simple Web Service Application Using SAP NetWeaver Developer Studio & SAP XI 3.0

Accessing DB2 Everyplace using J2ME devices, part 1

Using the VMware vcenter Orchestrator Client. vrealize Orchestrator 5.5.1

Program Download and install from the web site the latest free version of soapui ( )

Using the TekScope IVI-COM Driver from C#.NET

Introduction to IBM Rational HATS For IBM System z (3270)

Building JavaServer Faces Applications

"Charting the Course... MOC A Introduction to Web Development with Microsoft Visual Studio Course Summary

Working with Structured Data in Microsoft Office SharePoint Server 2007 (Part 4): SharePoint Designer

IBM DB2 Web Query for IBM i. Version 2 Release 2

Oracle Entitlements Server 11gR2 Integration Guide Published: May 2013

B. Assets are shared-by-copy by default; convert the library into *.jar and configure it as a shared library on the server runtime.

OSIsoft PI Custom Datasource. User Guide

ER/Studio Enterprise Portal User Guide

xtrace Monitor Installation Guide

Tutorial. Building Composite Applications for IBM Lotus Notes 8. For use with the IBM Lotus Notes 8 Beta 2 client

SUREedge DR Installation Guide for Windows Hyper-V

Tutorial: Consuming Web Services in Web Dynpro Java

Using the vcenter Orchestrator SOAP Plug-In 1.0.1

Getting started with WebSphere Portlet Factory V7.0.0

JMP305: JumpStart Your Multi-Channel Digital Experience Development with Web Experience Factory IBM Corporation

IBM. IBM i2 Analyze Windows Upgrade Guide. Version 4 Release 1 SC

Follow all of the steps indicated below for each process. Some steps may require IT assistance.

Using the Altova Tools with IBM DB2 purexml

How To Generate XSD Schemas from Existing MDM Repositories

Transcription:

Developing an app using Web Services, DB2, and.net http://www7b.software.ibm.com/dmdd/ Table of contents If you're viewing this document online, you can click any of the topics below to link directly to that section. 1. Before you start... 2 2. Overview... 4 3. Getting started... 6 4. Setting up the database... 8 5. Working with the GetRateWS function... 10 6. Creating a customer application... 13 7. How it all works... 19 8. Summary and resources... 20 Developing an app using Web Services, DB2, and.net Page 1 of 20

http://www7b.software.ibm.com/dmdd/ Section 1. Before you start About this tutorial In this tutorial, you will build a sample customer application that invokes Web services as user defined functions. This tutorial demonstrates how Web services calls can be easily combined with SQL to create DB2 applications on the Windows platform. You will use IBM DB2 Add-ins for Visual Studio.Net to create this application. IBM DB2 Add-ins provide rapid application development for DB2 Universal Database on Microsoft Visual Studio.NET. Should I take this tutorial? You should take this tutorial if: You want to develop windows applications to invoke Web services using DB2 and SQL. You want to learn more about using the DB2 Development Add-ins for Visual Studio.NET to rapidly create such Windows applications. Prerequisites To complete the steps in this tutorial, you need the following software from IBM and Microsoft: IBM DB2 Universal Database V8.1.2 Application Development Client Microsoft Visual Studio.NET About the author Sonali Surange is an Advisory Software Engineer working at the IBM San Francisco lab, on Data Management Application Development Tools. Currently, Sonali is working on providing tools for seamless integration with IBM Servers on Visual Studio.Net. Page 2 of 20 Developing an app using Web Services, DB2, and.net

http://www7b.software.ibm.com/dmdd/ Trademarks IBM, DB2 and DB2 Universal Database are registered trademarks of the IBM Corporation in the United States and/or other countries. Microsoft and Windows are registered trademarks of Microsoft Corporation in the United States, other countries, or both. Other company, product and service names may be trademarks or service marks of others. Developing an app using Web Services, DB2, and.net Page 3 of 20

http://www7b.software.ibm.com/dmdd/ Section 2. Overview Web services functions DB2 Universal Database can optimize access to Web services by using SQL statements to consume Web services data. DB2 table or scalar functions are created from WSDL interfaces that define the Web service. The data returned from the Web service can then be used within the context of your SQL, and in your DB2 applications. Sample customer application In this sample customer application, you will create a customer table in the DB2 database using the SQL scripts provided as part of the download for this tutorial. The customer table contains customer orders; each order contains a customer number and order in USD. Using the SQL scripts provided, you will also create a Web service user defined function. This user defined function will consume a currency conversion Web service from www.xmethods.net. You will use this function to obtain the live conversion rate from USD to EUROS. You will need a live connection to the Internet. Finally, you will update the converted currency amount in the database. The main steps are as follows: Page 4 of 20 Developing an app using Web Services, DB2, and.net

http://www7b.software.ibm.com/dmdd/ Enable DB2 for Web service user defined functions. Set up tracing to view soap request and response messages (optional). Create and initialize the customer table and create the GetRateWS Web service user defined function. View and run the Web service user defined function using IBM Explorer. Create Windows applications to invoke the Web services user defined function. From the windows application, update the DB2 table with the values obtained. This tutorial demonstrates: Creating the Web Service user defined function using IBM DB2 Projects. Working with the created function using IBM Explorer to: 1. View the source 2. Execute the function Viewing the soap request and response messages using tracing. Creating a Windows application to invoke the above function. Updating the data received back in the DB2 table. Developing an app using Web Services, DB2, and.net Page 5 of 20

http://www7b.software.ibm.com/dmdd/ Section 3. Getting started Enable DB2 for Web service user defined functions To use Web services consumer user defined functions, you first have to create helper functions on your database that are required for this functionality. Follow the steps below. 1. Enable DB2 for XML Extender. To enable the sample database for XML Extender, run the following command from a DB2 command prompt: dxxadm enable_db sample Replace sample with the appropriate name if you choose to work with another database. 2. Enable DB2 for Web service user defined functions. To enable the sample database for Web service user defined functions, run the following command from a DB2 command prompt: db2enable_soap_udf -n sample -u db2admin -p db2admin. Replace sample, username, and password with an appropriate database name, your DB2 username and password. Verify that the database was enabled To make sure the database was enabled: 1. Click View => IBM Explorer to open the IBM Explorer window. 2. Add a connection to the sample database, or the appropriate database enabled in the earlier step. 3. Under the Functions folder in IBM Explorer, you will see the DB2 user defined functions required for the XML extender, as shown below. Page 6 of 20 Developing an app using Web Services, DB2, and.net

http://www7b.software.ibm.com/dmdd/ 4. Under the Functions folder in IBM Explorer, you will see the DB2 user defined functions required for the Web services functionality, as shown below. Set up tracing to view soap messages You can optionally trace soap request and response messages when the Web service is invoked. These messages are saved into a file on your machine. To set up tracing, set the system environment variable DB2SOAP_TRACE to a fully qualified file name. DB2SOAP_TRACE=c:\db2vsnetsoap_trace\db2vsnetsoap_trace.xml. Developing an app using Web Services, DB2, and.net Page 7 of 20

http://www7b.software.ibm.com/dmdd/ Section 4. Setting up the database Create database objects Download the sql scripts included with this tutorial. Use the IBM DB2 projects to create these objects. View the user defined function Using IBM Explorer, view the function that was created in the earlier step. 1. Add a filter to the functions folder to view all functions for your schema. Click Functions => Filter. 2. Enter a schema name in the Schema field. Page 8 of 20 Developing an app using Web Services, DB2, and.net

http://www7b.software.ibm.com/dmdd/ Developing an app using Web Services, DB2, and.net Page 9 of 20

http://www7b.software.ibm.com/dmdd/ Section 5. Working with the GetRateWS function Executing the GetRateWS function Using IBM Explorer, you can perform tasks such as executing the GetRateWS function or viewing the source of this function. 1. Right-click the GetRateWS function and select Run function from the menu. 2. Add parameters to run this function. For example, add US and EURO to obtain conversion rate from USD to EUROS. 3. Click OK. 4. You will see the conversion rate in the grid. The GetRateWS function has obtained the live conversion rate from the Web service running at www.xmethods.net. Page 10 of 20 Developing an app using Web Services, DB2, and.net

http://www7b.software.ibm.com/dmdd/ Viewing the soap messages in trace Viewing the source To view the source for the GetRateWS function: 1. Right-click GetRateWS and select View Source. 2. View the source of this function in the IBM DB2 editor. Developing an app using Web Services, DB2, and.net Page 11 of 20

http://www7b.software.ibm.com/dmdd/ Page 12 of 20 Developing an app using Web Services, DB2, and.net

http://www7b.software.ibm.com/dmdd/ Section 6. Creating a customer application Create a Windows application Using the IBM DB2 Add-ins, create a Windows application to invoke the getratews Web service created in the previous section. To create a data-bound Windows application: 1. Create a Windows C# application and name it customerapp. 2. Open Form1.cs in design mode. 3. Drag and drop a Windows data grid control on the form. Use this to data-bind the customer table. 4. Drag and drop the customer table from IBM Explorer. This creates db2dataadapter1. 5. Click on db2dataadapter1 and generate DataSet. Name the dataset DB2DataSet_customer. 6. Set the DataSource property of the datagrid1 to DB2DataSet_customer.CUSTOMER. This binds the data grid to the Developing an app using Web Services, DB2, and.net Page 13 of 20

http://www7b.software.ibm.com/dmdd/ dataset at design time. 7. Add the following code (bold) in the beginning of Form1.cs: using IBM.Data.DB2; 8. Write the following code (bold) in the form load event handlers for the form: private void form1_load(object sender, System.EventArgs e) { this.db2dataadapter1.fill(this.db2dataset_customer); } Update the currency amount To update the currency amount: 1. Open Form1.cs in design mode. 2. Drag and drop a button onto the form and set the Name property to updateeuroamt and the text property to "Update Amount in Euros". 3. Click on db2dataadapter1 and in the properties section, select the Update Command property. Change the command text for the update command to the SQL (bold) listed below. Replace the schema name ssurange with the schema name used to create getratews and customer. Page 14 of 20 Developing an app using Web Services, DB2, and.net

http://www7b.software.ibm.com/dmdd/ update SSURANGE.CUSTOMER SET euroamt=decimal(getratews('us','euro') *decimal(usdamt,7,2),7,2) 4. Add the following code (bold) in the click event handler for the updateeuroamt button. private void updateeuroamt_click(object sender, System.EventArgs e) { try { this.db2dataadapter1.updatecommand.connection.open(); int count = this.db2dataadapter1.updatecommand.executenonquery if ( count > 0 ) { MessageBox.Show("Euro amount successfully updated using a live conversion rate!"); } } catch ( DB2Exception exp ) { MessageBox.Show(exp.Message); } } Refresh values from the database To view the updated currency values from the database: 1. Open Form1.cs in design mode. 2. Drag and drop a button onto the form and set the Name property to refresh and its text property to "Refresh From Database". Developing an app using Web Services, DB2, and.net Page 15 of 20

http://www7b.software.ibm.com/dmdd/ 3. Write the following code (bold) in the refresh button click event handler for the form: private void refresh_click(object sender, System.EventArgs e) { this.db2dataadapter1.fill(this.db2dataset_customer); } 4. Right click on the customerapp project and mark it as a Start-up project. 5. Build the customerapp project. Testing the customer application To test the customer application: 1. Run the customer application. View the values of the customer's order in USD from the customer table. Page 16 of 20 Developing an app using Web Services, DB2, and.net

http://www7b.software.ibm.com/dmdd/ 2. Click Update Euro Amount. View the message, "Euro amount successfully updated using a live conversion rate!" 3. Click Refresh to view the values in Euros in the grid. The values are USD amount converted to EURO amount, based on the conversion rate at the time the update button is clicked. Developing an app using Web Services, DB2, and.net Page 17 of 20

http://www7b.software.ibm.com/dmdd/ Page 18 of 20 Developing an app using Web Services, DB2, and.net

http://www7b.software.ibm.com/dmdd/ Section 7. How it all works How it all works A customer table is created with customer order amounts in USD. This is data bound to the data grid using the data adapter db2dataadapter1, which is created for the customer table. When the application starts, the select statement of the data adapter is executed and the existing orders with USD amounts are displayed. The update command for db2dataadapter1 is used to calculate and update the corresponding EURO amounts. The conversion rate is obtained by running the GetRateWS user defined function; that in turn invokes the currency conversion Web service from www.xmethds.net. The rate obtained is applied to each of the USD amounts to obtain their corresponding EURO amounts. All of the above is achieved by running one SQL statement as listed below: update SSURANGE.CUSTOMER SET euroamt=decimal(getratews('us','euro') *decimal(usdamt,7,2),7,2) Developing an app using Web Services, DB2, and.net Page 19 of 20

http://www7b.software.ibm.com/dmdd/ Section 8. Summary and resources Summary You used the IBM DB2 Add-ins for Microsoft Visual Studio.Net to create tables, and DB2 Web Service User Defined functions. You used IBM Explorer to run the Web service user defined function to get a live currency conversion rate, and to view the source for this function. You also used soap tracing to view the soap request and response sent and recieved when the Web service user defined function was executed. Using IBM Explorer, you successfully created the sample windows application to view and update the DB2 table information using SQL to invoke Web services. Resources Refer to the following resources for more information: IBM DB2 Development Add-ins for Visual Studio.Net Developing DB2 UDB Database Projects in Visual Studio.Net Exploring DB2 Data Connections in Visual Studio.Net Developing Web Services and Messaging DB2 Applications Developing an application using Websphere MQ and Visual Studio.Net Feedback Colophon This tutorial was written entirely in XML, using the developerworks Toot-O-Matic tutorial generator. The open source Toot-O-Matic tool is an XSLT stylesheet and several XSLT extension functions that convert an XML file into a number of HTML pages, a zip file, JPEG heading graphics, and two PDF files. Our ability to generate multiple text and binary formats from a single source file illustrates the power and flexibility of XML. (It also saves our production team a great deal of time and effort.) For more information about the Toot-O-Matic, visit http://www-106.ibm.com/developerworks/edu/x-dw-toottut-i.html. Page 20 of 20 Developing an app using Web Services, DB2, and.net