-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: sachinvr
Message 2 in Discussion






 Hi,
 
Try this and let me know whether this is what you intend to achieve.

Sample WebMethod code is as below.

Public Class HelloWorld 
    Inherits System.Web.Services.WebService 


    Public Sub New() 
      MyBase.New() 
    End Sub 


    <WebMethod()> Public Function Hello(ByVal Name As String) As String 
      Return "Hello " & Name 
    End Function 


End Class 


Make sure MSXML parser version 3 or greater is installed on your SQL server. In 
SQL create the following stored procedure. 


Create procedure http_get( @sUrl varchar(200), @response varchar(8000) out) 
As

   Declare   @obj   int  ,@hr   int  ,@status int  ,@msg varchar(255) 

   exec @hr = sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT 
   if @hr < 0
   begin
    Raiserror('sp_OACreate MSXML2.ServerXMLHttp failed', 16, 1) 
    return 
   end 
   
   exec @hr = sp_OAMethod @obj, 'Open', NULL, 'GET', @sUrl, false 
   if @hr <0 
   begin 
    set @msg = 'sp_OAMethod Open failed' 
    goto eh 
   end 
   
   exec @hr = sp_OAMethod @obj, 'send' 
   if @hr <0 begin  set @msg = 'sp_OAMethod Send failed' goto eh end 

  exec @hr = sp_OAGetProperty @obj, 'status', @status OUT 
  if @hr <0 
  begin  
   set @msg = 'sp_OAMethod read status failed' 
   goto eh 
  end 
  if @status <> 200  
    begin set @msg = 'sp_OAMethod http status ' + str(@status) 
    goto eh 
  end 
   
  exec @hr = sp_OAGetProperty @obj, 'responseText', @response OUT 
  if @hr <0 
  begin  
   set @msg = 'sp_OAMethod read response failed' 
   goto eh 
  end 
  exec @hr = sp_OADestroy @obj 
  return 

--Error handling code
eh: 
  exec @hr = sp_OADestroy @obj 
  Raiserror(@msg, 16, 1) 
  return
go 


then run this
declare @resp varchar(8000) 
exec http_get 
'http://[webserver]/[virtualDirectory]/HelloWorld.asmx/Hello?Name=david',@resp 
out 
print @resp 

 
Regards,
SACHIN RAIKAR
 
-------Original Message-------
 

From: MumbaiUserGroup
Date: 05/19/06 21:59:30
To: MumbaiUserGroup
Subject: Calling Web Service through SQL SERVER (TSQL)
 




New Message on MumbaiUserGroup



Calling Web Service through SQL SERVER (TSQL)





Reply





 
Reply to Sender   <FONT" width=16 align=middle border=0 size="1" 
face="Verdana,Arial,Helvetica,Sans Serif">Recommend 
Message 1 in Discussion 





From: cool 


Hi,
I have a web service. I need to create a stored procedure that calls a 
WebMethod provided by the web service and updates the Database.
Have any one done this kind of stored procedure that to communicate with web 
service.
Any kind or suggestion or sample code?? please help me if any one can.
View other groups in this category. 


 









-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to