Thursday, March 29, 2012

endpoints

I am trying to find info / examples of how to send information to a webservice using sql server is that at all possible.

the following code might help you,

Code Snippet

Declare @.Object as Int;

Declare @.ResponseText as Varchar(8000);

Exec sp_OACreate 'MSXML2.XMLHTTP', @.Object OUT;

Exec sp_OAMethod @.Object, 'open', NULL, 'get',

'http://www.webservicex.com/stockquote.asmx/GetQuote?symbol=MSFT', --Your Web Url (invoked)

'false'

Exec sp_OAMethod @.Object, 'send'

Exec sp_OAMethod @.Object, 'responseText', @.ResponseText OUTPUT

Select @.ResponseText

Exec sp_OADestroy @.Object

|||Thanks Manivannan

so i am assuming that if i wanted to send an xml file to a url i would use method with 'post'

Exec sp_OAMethod @.Object, 'open', NULL, 'post', 'myurl', 'false'

and then send right?
|||I using the the example you gave me and trying to post this xml file

Declare @.Object as Int;

Declare @.ResponseText as Varchar(8000);
Declare @.xmlData xml

select @.xmlData = c
FROM OPENROWSET (
BULK 'E:\StockQuote.xml',SINGLE_BLOB) as TEMP(C)

Exec sp_OACreate 'MSXML2.XMLHTTP', @.Object OUT;

Exec sp_OAMethod @.Object, 'open', NULL, 'post',

'http://www.webservicex.com/stockquote.asmx/GetQuote', --Your Web Url (invoked)

'false'

Exec sp_OAMethod @.Object, 'send', NULL, @.xmlData

Exec sp_OAMethod @.Object, 'responseText', @.ResponseText OUTPUT
Select @.ResponseText

Exec sp_OADestroy @.Object

I am not getting back a response just like the example you gave insteadi get null what am i doing wrong i am trying to figure out how to post some XML file here is the xml i am trying to post

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlnsoap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetQuote xmlns="http://www.webserviceX.NET/">
<symbol>MSFT</symbol>
</GetQuote>
</soap:Body>
</soap:Envelope>

sql

No comments:

Post a Comment