Stored procedure call webservice

Webservice call a stored procedure call is actually using the OLE system function in the database.

1. Find webservice api available MSSOAP.SoapClient.

2. Find the API interface available mssoapinit method.

3. Find the database to perform OLE functions sp_OACreate, sp_OAMethod, sp_OADestroy.

Here basically completed, Here is the complete stored procedure.

--set SoapClient to be work
sp_configure 'Ole Automation Procedures',1 
reconfigure 
go 


DECLARE @object int
DECLARE @hr int
DECLARE @result int
DECLARE @objectResult nvarchar(255)

--sp_OACreate see more. http://msdn.microsoft.com/en-in/library/ms189763.aspx
EXEC @hr = sp_OACreate 'MSSOAP.SoapClient', @object OUT
EXEC @hr = sp_OAMethod @object, 'mssoapinit', null, 'http://localhost:52607/WebService1.asmx?WSDL','WebService1'
EXEC @hr = sp_OAMethod @object,'HelloWorld',@objectResult OUT

print @hr

IF @hr <> 0
BEGIN
  EXEC sp_OAGetErrorInfo @object   
  print @object
END
ELSE
BEGIN
 print @objectResult
end
EXEC @hr = sp_OADestroy @object
GO

  

Reproduced in: https: //www.cnblogs.com/Alenliu/p/5159857.html

Guess you like

Origin blog.csdn.net/weixin_33802505/article/details/93470088