sp_OAMethod Send failed
i m configuring sms sending service in sql server 2005.
i have stored procedure SENDSMS which sends the sms to mobile number.
where i m creating procedure on the server which have SMS server installed,it is sending sms.
but when i m executing procedure in my local system then it is giving error
"Msg 50000, Level 16, State 1, Procedure sendsms, Line 42
sp_OAMethod Send failed"
Please advice.
should there be any system confifuration to send sms .
i m sending my code for ur review.
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[sendsms](@msisdn varchar(10), @toAddress varchar(8000), @message
varchar(1000))
--here we are passing the all required parameters
-- msisdn - in this parameter pass the Message Sender's Mobile No.
-- toAddress - Here we can Pass More than one Reciever's Mobile Nos. if there are more than
--one mobile no. then please sepaerate by comma
-- message - Actual Message content
-- here we require one more parameter
-- Name - since it is fixed in our case so I just added name=Oxigen in get query
As
Declare
@obj int
,@hr int
,@status int
,@msg varchar(255)
,@sUrl varchar(200)
,@response varchar(8000)
-- this is the actual get query message which will post to the server
set @sUrl = 'http://Messagebridge.net:8000/smsgateway?name=Oxigen&msisdn=' + @msisdn + '&toAddress=' + @toAddress +
'&message=' + @message
--print @sUrl
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
eh:
exec @hr = sp_OADestroy @obj
Raiserror(@msg, 16, 1)
return
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
anurag sharma
|