HTTP POST in SQL Server 2005
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 [at] iHr = sp_oaCreate 'Msxml2.ServerXMLHTTP.3.0', [at] iObject OUTPUT
declare [at] data as nvarchar(max)
set [at] data = 'boo=yeah'
EXEC [at] iHr = sp_OAMethod [at] iObject, 'Open', null,
'POST', [at] smtpWebService, 0
EXEC [at] iHr = sp_OAMethod [at] iObject, 'setRequestHeader', null, 'Content-
Type', 'application/x-www-form-urlencoded'
EXEC [at] iHr = sp_OAMethod [at] iObject, 'send',null, [at] data
while [at] State<>4
begin
exec sp_oagetproperty [at] iObject, 'readyState', [at] State output
end
EXEC [at] iHr = sp_OAGetProperty [at] iObject, 'responseText', [at] retVal OUT
print [at] retVal
EXEC sp_OADestroy [at] iObject
Re: HTTP POST in SQL Server 2005
Nick Chan (zzzxtreme [at] 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 [at] 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
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 <esq... [at] sommarskog.se> wrote:
> Nick Chan (zzzxtr... [at] 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... [at] 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