Uploaded by greenford walter katuruza

How to invoke a Web Service from a Stored Procedure - CodeProject

advertisement
How to invoke a Web Service from a Stored Procedure - CodeProject
1 of 10
https://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-...
1
15,013,629 members
351 Member 15344965
Search for articles, questions, tips
articles
quick answers
discussions
features
community
Articles / Web Development / ASP.NET
help
Watch
How to invoke a Web Service from a Stored Procedure
Rate me:
Omar Frometa
26 Jul 2012
CPOL
4.91/5 (65 votes)
2 min read
Learning how to make a call to a Web Service from a Stored Procedure.
Is your email address OK? You are signed up for our newsletters but your email address is either unconfirmed, or
has not been reconfirmed in a long time. Please click here to have a confirmation email sent so we can confirm
your email address and start sending you newsletters again. Alternatively, you can update your subscriptions.
Introduction
On one occasion an old friend, was planning some applications using NET and sockets, and needed to call a WebServices from a
stored procedure.
In this article I will share this experience so that other programmers can learn to call a WebService sending parameters from a
Stored Procedure.
Step 1
We must create our WebServices Project in Visual Studio.
2/9/2021, 17:55
How to invoke a Web Service from a Stored Procedure - CodeProject
2 of 10
https://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-...
Step 2
Then proceed to create the methods that we use in our service, in my case believe 6 methods which are: Greet (string
Param1) and expects a String as the parameter, HelloWord() does not expect any parameters, and the Add,
subtract, and Divide proliferation (Num1 int, int num2) want two integers as parameters.
Step 3
2/9/2021, 17:55
How to invoke a Web Service from a Stored Procedure - CodeProject
3 of 10
https://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-...
Proceed to create our stored procedure that will have all the code to invoke the Web Services we have just created, as in all my
articles database I use is AdventureWorks, which is the basis of test data that brings SQL Server.
Step 4
Then publish the web service on our IIS Web Server
2/9/2021, 17:55
How to invoke a Web Service from a Stored Procedure - CodeProject
4 of 10
https://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-...
Step 5
We proceed to our Store Procedure Coding the data of our Web Service.
Step 6
In the procedure to create, we pass a parameter which is the parameter that is waiting Saludar() method, if they want to use
the other methods, should create another parameter because as I mentioned above the other methods are expecting 2 parameters
integer type.
Something that is also very important when using the
sp_OAMethod Stored Procedure this awaiting the POST or GET method,
2/9/2021, 17:55
How to invoke a Web Service from a Stored Procedure - CodeProject
5 of 10
https://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-...
default almost always send POST, but if we sent this method, we can not display the XML reading generated by our Web Service,
so we must use the GET method.
Step 7
Proceed to test our Web Service through your browser, type the address of the IIS where the published our Web Service.
http://localhost/WebServices/Service1.asmx in the same show all the methods that we created in our Web Service.
Step 8
Select the method that we use and invoke from our Stored Procedure,
want to happen to the Web Service, after this we click on Invoke.
Saludar(). Then proceed to write the parameter you
2/9/2021, 17:55
How to invoke a Web Service from a Stored Procedure - CodeProject
6 of 10
https://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-...
Step 9
After that it will open another page in your browser, the information contained in XML and the parameter to write.
Step 10
We proceed to execute the stored procedure we just created to invoke our web service.
2/9/2021, 17:55
How to invoke a Web Service from a Stored Procedure - CodeProject
7 of 10
https://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-...
Step 11
After running our procedure and send our parameters we get the same result we got when we run it through your browser.
Results
Look at the comparison and noticed that the same result.
2/9/2021, 17:55
How to invoke a Web Service from a Stored Procedure - CodeProject
8 of 10
https://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-...
License
This article, along with any associated source code and files, is licensed
under The Code Project Open License (CPOL)
Share
SonarCloud
SonarCloud
About the Author
Omar
Frometa
CEO FV Tech
Dominican Republic
Watch
this Member
MCTS - SQL Server 2008
Microsoft Certified Technology Specialist
CETEX - Exactus ERP
Exactus Technician Certificate
Comments and Discussions
2/9/2021, 17:55
How to invoke a Web Service from a Stored Procedure - CodeProject
9 of 10
https://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-...
Email Alerts
Add a Comment or Question
Spacing Relaxed
Search Comments
Layout Normal
Per page 25
Update
First Prev Next
My vote of 5
MARLON ALEXANDER
QUINTERO GARRIDO
Getting Null Response
Member 11505628
26-Jun-19 6:57
Question
Member 12799217
26-Jun-19 4:44
how can return multi values from web service and using
it in stored proceduer
Member 10659992
30-Jul-18 16:19
various parameters
Member 13596494
13-Mar-18 19:40
problem with 3parameters
Member 13510881
8-Nov-17 21:48
I get null value when executing this procedure
Member 11859933
6-Jul-17 9:15
Re: I get null value when executing this procedure
Getting NULL Response
Re: Getting NULL Response
18-May-21 23:11
Member 13596494
13-Mar-18 19:59
Member 10021395
2-May-17 16:20
ekiran143
5-May-17 7:29
Calling web service through stored procedure
hemant bhor
Use of User and Password in the WebServices
Member 11694219
15-May-15 23:39
My vote of 5
mfp@novosoft.eu
18-Mar-15 17:27
My vote of 5
Humayun Kabir Mamun
Null value Return from SP
mudgilsks
Permalink
AdvertiseRe: Null value Return from
Privacy
Cookies
Will this work in SQL 2005?
Terms of Use
Layout: fixed | fluid
SP
Getting Null Response
rollypsp
19-May-15 7:17
2-Mar-15 7:38
4-Dec-14 15:17
Article Copyright 2012 by Omar Frometa
Everything else Copyright
© CodeProject,
15-Jan-15
21:01
1999-2021
Member 10735926
14-Oct-14 8:01
Web03 2.8.20210901.1
Ashish Kumar kansal
19-Sep-14 9:38
Omar Frometa
19-Sep-14 14:21
My vote of 5
Mladen Borojevic
22-Aug-14 9:50
My Vote of 5*
Mas11
13-Mar-14 8:26
Need how to call WCF Service from strored procedure.
tosukum
23-Dec-13 8:26
Custom Soap Headers
alemos
Returing Null
vijay kumar bollu
Re: Getting Null Response
11-Dec-13 15:12
30-Aug-13 7:27
2/9/2021, 17:55
How to invoke a Web Service from a Stored Procedure - CodeProject
10 of 10
https://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-...
Getting a null response.
Last Visit: 2-Sep-21 17:10
General
News
PulkitGulati
Refresh
Last Update: 2-Sep-21 17:43
Suggestion
Question
15-Jul-13 5:04
Bug
Answer
Joke
Praise
1 2 Next ᐅ
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
2/9/2021, 17:55
Download