lankapala
asked on
T-sql Web servcies
Hi,
I need to run .wdsl web service from T-sql (write stored procedure).Any idea
See link below
http://ws.afd.co.uk/PCE_WebService.asmx?WSDL
I need to run .wdsl web service from T-sql (write stored procedure).Any idea
See link below
http://ws.afd.co.uk/PCE_WebService.asmx?WSDL
Which SQL Server are you using SQL 2008 ?
For that i think you need to use SQL SERVER CLR or SSIS package.
For clr refer - https://blogs.msdn.microsoft.com/spike/2010/11/25/how-to-consume-a-web-service-from-within-sql-server-using-sql-clr/
For SSIS package - it is same as you call it in .NET code. here you need to use the script task.
Otherwise you can check the below code. TO consume a webservice you need 3 sps called sp_OACreate, sp_OAMethod and sp_OADestroy. I have created a stored procedure for you. If you want to pass the webservice name dynamically you can change it to parameters.
https://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-Service-from-a-Stored-Procedur
For that i think you need to use SQL SERVER CLR or SSIS package.
For clr refer - https://blogs.msdn.microsoft.com/spike/2010/11/25/how-to-consume-a-web-service-from-within-sql-server-using-sql-clr/
For SSIS package - it is same as you call it in .NET code. here you need to use the script task.
Otherwise you can check the below code. TO consume a webservice you need 3 sps called sp_OACreate, sp_OAMethod and sp_OADestroy. I have created a stored procedure for you. If you want to pass the webservice name dynamically you can change it to parameters.
CREATE PROC CallWebService
AS
BEGIN
Declare @Ob as Int, @ReturnData as Varchar(MAX);
Exec sp_OACreate 'MSXML2.XMLHTTP', @Ob OUT;
Exec sp_OAMethod @Ob, 'open', NULL, 'get', 'http://ws.afd.co.uk/PCE_WebService.asmx?WSDL','false'
Exec sp_OAMethod @Ob, 'send'
Exec sp_OAMethod @Ob, 'responseText', @ReturnData OUTPUT
Select @ReturnData
Exec sp_OADestroy @Ob
END
If you want to learn the entire code then you can follow from codeprojecthttps://www.codeproject.com/Articles/428200/How-to-invoke-a-Web-Service-from-a-Stored-Procedur
ASKER
Hi, I tried above codes many times.Never worked.That's the reason i asking how to do that.
if you go to
http://ws.afd.co.uk/PCE_WebService.asmx?WSDL
i'm looking how to pass parameters.
PCEWebService.PostcodeEver ywhere.Add ressList(S tring strSerialNumber, String strPassword, String strUserID, String strPostcode, String strProperty, String strCountyType)
if you go to
http://ws.afd.co.uk/PCE_WebService.asmx?WSDL
i'm looking how to pass parameters.
PCEWebService.PostcodeEver
ASKER
Hi Tried using following way but it's working in the IE explorer
but not in the SQL
http://ws.afd.co.uk/PCE_WebService.asmx/AddressList?strSerialNumber=1111&strPassword=xxxxx&strUserID=sert&strPostcode=NE3%202NS&strProperty=&strCountyType=
but not in the SQL
http://ws.afd.co.uk/PCE_WebService.asmx/AddressList?strSerialNumber=1111&strPassword=xxxxx&strUserID=sert&strPostcode=NE3%202NS&strProperty=&strCountyType=
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> I tried above codes many times.Never worked.That's the reason i asking how to do that.
asking again - Which version of SQL Server are you using?
asking again - Which version of SQL Server are you using?
ASKER
@Kyle Abrahams
I used same exactly like you used,But still not working see my code
http://ws.afd.co.uk/PCE_WebService.asmx/AddressList?strSerialNumber=1111&strPassword=444&strUserID=Test1&strPostcode=NE3%202NS&strProperty=&strCountyType=Tyne
This is working in the IE explore,But not the SQL server
and also i'm getting error message From your code + (+ @AirportCode) Incorrect syntax near +
Exec sp_OAMethod @Object, 'open', NULL, 'get', 'http://www.webservicex.net/airport.asmx/getAirportInformationByAirportCode?airportCode=' + @AirportCode,'false'
I used same exactly like you used,But still not working see my code
http://ws.afd.co.uk/PCE_WebService.asmx/AddressList?strSerialNumber=1111&strPassword=444&strUserID=Test1&strPostcode=NE3%202NS&strProperty=&strCountyType=Tyne
This is working in the IE explore,But not the SQL server
and also i'm getting error message From your code + (+ @AirportCode) Incorrect syntax near +
Exec sp_OAMethod @Object, 'open', NULL, 'get', 'http://www.webservicex.net/airport.asmx/getAirportInformationByAirportCode?airportCode=' + @AirportCode,'false'
ASKER
@Pawan Kumar
Sql Server 2008R2
Sql Server 2008R2
can you pls share your entire code. Will fix.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@Pawan Kumar:
Still NULL retun
But sameway it's working at IE browser
Still NULL retun
But sameway it's working at IE browser
Al@author
Do u know any parameter values where for which it will return value?
Do u know any parameter values where for which it will return value?
Select @ReturnData?
I think is once you pass proper values of parameters then you will get proper response if it is there. My code is working fine.
EXEC CallWebService '1111','444','Test1','NE3 2NS','','Tyne'
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Question abandoned
Provided multiple solutions.
Provided multiple solutions.
Open in new window