title: Call Web Service from SQL Server
body: <p>I have a web service with a web method which echoes whatever you pass it.</p>
  
  <p>I try to call my web method from T-SQL code but it neither works nor yields any exception or error. </p>
  
  <p>Here's the code: </p>
  
  <pre><code>sp_configure 'show advanced options', 1;
  GO
  
  RECONFIGURE;
  GO
  
  sp_configure 'Ole Automation Procedures', 1;
  GO
  
  RECONFIGURE;
  GO
  
  Declare @Object as Int;
  Declare @ResponseText as Varchar(8000);
  
  Exec sp_OACreate 'MSXML2.ServerXMLHTTP', @Object OUT;
  
  Exec sp_OAMethod @Object, 'open', NULL, 'get',
      'http://vserver250:8600/EcomSmsSvc.asmx/Reply?message=hi','false'
  
  Exec sp_OAMethod @Object, 'send'
  
  Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
  
  Select @ResponseText
  
  Exec sp_OADestroy @Object
  </code></pre>
  
  <p>My web service works fine, and when I call it through web browsers it returns the message I send it, but when I call it from T-SQL the result is always <code>NULL</code>.  </p>
  
  <p>Can anyone help me find out where the problem is? </p>