Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 XML Post

Author  Topic 

darrenkelly
Starting Member

2 Posts

Posted - 2003-03-27 : 07:08:29
Hi, I hope someone can help me here. From an .ASP page I receive an XML feed parse it and enter it into the database. Then an SP manlipulates the data. Depending on the outcome I need the SP to send an XML string back to an .ASP page on a Web Server. I use the following code which is causing me an error when I try and send data. It comes up with the following error "Error Message: sp_OAMethod usage: ObjPointer". Does anyone know why.

Also when I open the URL does anyone know why NULL is required as a parameter???

I am not sure I am on the right track or what I am trying to do is possible in this context. Any information would be greatly appreciated. Below is the code I am using....

Many thanks.

----DECLARING Stored Procedure Variables
DECLARE @Sp_Name varchar(100)
DECLARE @Return_Value integer
DECLARE @Error_Message varchar(200) --@Error_No IF 0 all is okay, if anything else something is wrong.
DECLARE @Error_No integer
DECLARE @XMLDoc int

DECLARE @src varchar(255)
DECLARE @desc varchar(255)
Declare @URL varchar (255)
Declare @XML varchar (255)

--SETTING Stored Procedure Variables
SET @Sp_Name = '_sp_SendXML'
SET @Return_Value = 0
SET @Error_Message = ' '
SET @Error_No = 0

--Create Object
EXECUTE @Error_No = sp_OACreate 'Microsoft.XMLHTTP', @XMLDoc OUT
IF @Error_No != 0
BEGIN
EXEC sp_OAGetErrorInfo @XMLDoc, @src OUT, @desc OUT
PRINT 'Problem Opening Method OPEN'
PRINT 'Error Message: ' + CAST(@desc AS VARCHAR)
PRINT 'Error No: ' + CAST(@Error_No AS VARCHAR)
PRINT 'Error Source: ' + CAST(@src AS VARCHAR)
RETURN
END

--Open Object
SET @URL = '"http:\\miranda\ebit.test.asp\test.asp"'
EXECUTE @Error_No = sp_OAMethod @XMLDoc, 'OPEN',NULL,'"POST"',@URL, FALSE
IF @Error_No != 0
BEGIN
EXEC sp_OAGetErrorInfo @XMLDoc, @src OUT, @desc OUT
PRINT 'Problem Opening Method Request Header'
PRINT 'Error Message: ' + CAST(@desc AS VARCHAR)
PRINT 'Error No: ' + CAST(@Error_No AS VARCHAR)
PRINT 'Error Source: ' + CAST(@src AS VARCHAR)
RETURN
END

--Send Object
SET @XML = 'id=HELLO'
EXECUTE @Error_No = sp_OAMethod @XMLDoc,
'SEND', @XML
IF @Error_No != 0
BEGIN
EXEC sp_OAGetErrorInfo @XMLDoc, @src OUT, @desc OUT
PRINT 'Problem Opening Method Send'
PRINT 'Error Message: ' + CAST(@desc AS VARCHAR)
PRINT 'Error No: ' + CAST(@Error_No AS VARCHAR)
PRINT 'Error Source: ' + CAST(@src AS VARCHAR)
RETURN
END

--Destroy Object
EXECUTE @Error_No = sp_OADestroy @XMLDoc
IF @Error_No != 0
BEGIN
EXEC sp_OAGetErrorInfo @XMLDoc, @src OUT, @desc OUT
PRINT 'Problem Opening Method Send'
PRINT 'Error Message: ' + CAST(@desc AS VARCHAR)
PRINT 'Error No: ' + CAST(@Error_No AS VARCHAR)
PRINT 'Error Source: ' + CAST(@src AS VARCHAR)
RETURN
END

   

- Advertisement -