Solved

Web Service in Stored Procedure

Posted on 2013-01-22
4
949 Views
Last Modified: 2013-01-23
Hi,

  I have a web service that takes an input variable and displays an output variable.
  Can i embed this webservice in a DB2 stored Procedure and do some manipulations on my side? I'm on DB2 9.7

Thanks!
0
Comment
Question by:pvsbandi
  • 2
  • 2
4 Comments
 
LVL 35

Expert Comment

by:Gary Patterson
ID: 38809590
DB2 UDB 9.7 supports external stored procedures, which means you can write stored procedures in C,C++, Java, .NET CLR languages,or COBOL.

So, yes, you can certainly create a stored procedure that calls a web service.

- Gary Patterson
0
 

Author Comment

by:pvsbandi
ID: 38810426
Thanks! Do you have any example you can share with me?
0
 
LVL 35

Accepted Solution

by:
Gary Patterson earned 500 total points
ID: 38810616
I usually work on DB2 on IBM i, and so things may be a little different on other platforms.  I looked at the DB2 UDB 9 Info Center, and the process looks very similar, though.

Basically you need two things:

1)  Write a program that consumes the web service.  Normally you would use an integrated development tool like NetBeans or Visual Studio to take the web service WSDL and generate a skeleton program.  You alter the skeleton to do what you want (at a minimum you will probably need to build a parameter interface so you can pass parms when calling as a stored procedure).

2) Once that is tested and working, you'll need to use the DB2 CREATE PROCEDURE statement to create a stored procedure interface for the external program (Java, .NET, whatever).

Here are tutorials on create a simple web service, and then how to consume that web service:

Java:

http://netbeans.org/kb/docs/websvc/jax-ws.html

C#.NET:

http://johnwsaunders3.wordpress.com/2009/05/17/how-to-consume-a-web-service/

Here is the DB2 UDB 9 Info Center topic on External Stored Procedures:

http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=%2Fcom.ibm.db2.udb.apdv.sql.doc%2Fdoc%2Fc0020569.htm

Hope that helps.

- Gary Patterson
0
 

Author Closing Comment

by:pvsbandi
ID: 38811343
Thanks! Great help!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question