HTTP POST in SQL Server 2005
HTTP POST in SQL Server 2005
am 14.09.2007 10:48:12 von Nick Chan
hello, i have this summarized stored proc. Problem is, when using
'Send', my aspx page reads (asp.net)Request.Form as empty
However, when I use a simple html file to post, it works. Does anyone
know what's wrong?
EXEC @iHr = sp_oaCreate 'Msxml2.ServerXMLHTTP.3.0',@iObject OUTPUT
declare @data as nvarchar(max)
set @data = 'boo=yeah'
EXEC @iHr = sp_OAMethod @iObject, 'Open', null,
'POST',@smtpWebService, 0
EXEC @iHr = sp_OAMethod @iObject, 'setRequestHeader', null, 'Content-
Type', 'application/x-www-form-urlencoded'
EXEC @iHr = sp_OAMethod @iObject, 'send',null,@data
while @State<>4
begin
exec sp_oagetproperty @iObject, 'readyState', @State output
end
EXEC @iHr = sp_OAGetProperty @iObject, 'responseText',@retVal OUT
print @retVal
EXEC sp_OADestroy @iObject
Re: HTTP POST in SQL Server 2005
am 14.09.2007 23:42:52 von Erland Sommarskog
Nick Chan (zzzxtreme@yahoo.com) writes:
> hello, i have this summarized stored proc. Problem is, when using
> 'Send', my aspx page reads (asp.net)Request.Form as empty
>
> However, when I use a simple html file to post, it works. Does anyone
> know what's wrong?
I don't understand what you mean with "html file to post" or "send",
but then I am completely ignorant about web servers and ASP.
However, whatever you are doing, you should not use the sp_OAcreate
routines in SQL 2005. Write a stored procedure in .Net instead. If
you still have to call this Msxml2.ServerXMLHTTP object you will have
to make the assembly unsafe, but I think it's still better than
having to enable sp_OAmethod and granting privileges to it, as this
is a big security risk.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downlo ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books .mspx
Re: HTTP POST in SQL Server 2005
am 17.09.2007 04:30:24 von Nick Chan
hi thanks a lot for the reply
sorry i meant, when i create a html file to submit a http post thru a
browser, it works.
but i have taken ur advice and did a .net library. was much simpler
with system.net.webclient. thanks!
On Sep 15, 5:42 am, Erland Sommarskog wrote:
> Nick Chan (zzzxtr...@yahoo.com) writes:
> > hello, i have this summarized stored proc. Problem is, when using
> > 'Send', my aspx page reads (asp.net)Request.Form as empty
>
> > However, when I use a simple html file to post, it works. Does anyone
> > know what's wrong?
>
> I don't understand what you mean with "html file to post" or "send",
> but then I am completely ignorant about web servers and ASP.
>
> However, whatever you are doing, you should not use the sp_OAcreate
> routines in SQL 2005. Write a stored procedure in .Net instead. If
> you still have to call this Msxml2.ServerXMLHTTP object you will have
> to make the assembly unsafe, but I think it's still better than
> having to enable sp_OAmethod and granting privileges to it, as this
> is a big security risk.
>
> --
> Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se
>
> Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/down loads/books...
> Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/boo ks.mspx