Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Accessing webservices from DTS Activex Script

Reply
Thread Tools

Accessing webservices from DTS Activex Script

 
 
bryan.galaz@gmail.com
Guest
Posts: n/a
 
      05-17-2006
I need to call a .NET webservice from a SQL Server 2000 DTS package
Activex Script using VBScript. Does anyone know the syntax for this?

Thanks!

 
Reply With Quote
 
 
 
 
Adam Short
Guest
Posts: n/a
 
      01-12-2007
Not sure if you're still looking for a solution for this, but I came
across your post while looking for something else and just happened to
have the code handy.

It's a bit long-winded, but it works. You have to build the SOAP request
manually, but it's not too tricky, then you create an instance of the
XMLHTTP object and use it to send the request. The code below is from a
DTS ActiveX task I wrote a while back, the relevant data has been
changed to protect the guilty.

' Build the soap request for the mail sender web method.
dim SoapTest
SoapTest=""
SoapTest = SoapTest & "<?xml version=""1.0"" encoding=""utf-8""?>"
SoapTest = SoapTest & "<soap:Envelope
xmlnssi=""http://www.w3.org/2001/XMLSchema-instance""
xmlnssd=""http://www.w3.org/2001/XMLSchema""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
SoapTest = SoapTest & "<soap:Body>"
SoapTest = SoapTest & "<SendMail xmlns=""http://myhost/MailService"">"
SoapTest = SoapTest & "<SmtpServer>midas</SmtpServer>"
SoapTest = SoapTest & "<To>" & DTSGlobalVariables("recipients").Value &
"</To>"
SoapTest = SoapTest & "<From>" & DTSGlobalVariables("sender").Value &
"</From>"
SoapTest = SoapTest & "<Subject>Your Subject Here</Subject>"
SoapTest = SoapTest & "<Body>" & body & "</Body>"
SoapTest = SoapTest & "</SendMail>"
SoapTest = SoapTest & "</soap:Body>"
SoapTest = SoapTest & "</soap:Envelope>"

Set requestHTTP = CreateObject("Microsoft.XMLHTTP")
requestHTTP.open "POST", SoapServer, false
requestHTTP.setrequestheader "Content-Type", "text/xml"
requestHTTP.setrequestheader "SOAPAction",
"http://homer.ncha.net/MailService/SendMail" ' NOTE! READ this line
carefully before editing it!!
'It's the path to the .asmx file, with the filename replaced by
the name of the method you want to call.
requestHTTP.Send SoapTest

if requestHTTP.Status = 200 then
DTSGlobalVariables("success").Value=1
DTSGlobalVariables("status").Value= requestHTTP.status
DTSGlobalVariables("statusText").Value= requestHTTP.statusText
DTSGlobalVariables("responseText").Value= requestHTTP.responseText
Else
DTSGlobalVariables("success").Value=0
DTSGlobalVariables("status").Value= requestHTTP.status
DTSGlobalVariables("statusText").Value= requestHTTP.statusText
DTSGlobalVariables("responseText").Value= requestHTTP.responseText

' If the mail routine fails for any reason, write the output to a file
so we can see what happened.
set outfile=fs.createtextfile("C:\failedmail.html")
outfile.write( requestHTTP.responseText)
outfile.close
End if

That's pretty much it. The example is obviously a mail sender web
method, but it'll work with any kind of web service. It's not the most
elegant method in the world, but at least it works. I tried several
different ways of doing it before I finally gave in and did it the long
way.


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FA: DTS THE SHADOW ltbx LD, DTS DAZED & CONFUSED Crit. DVD, Criterion BOOGIE NIGHTS LD J Rusnak DVD Video 0 12-28-2006 05:30 PM
FA: DTS ANACONDA Superbit, Factory-Sealed DEEP RISING dvds, DTS CARLITO'S WAY ld J Rusnak DVD Video 0 04-11-2006 02:30 AM
ActiveX apologetic Larry Seltzer... "Sun paid for malicious ActiveX code, and Firefox is bad, bad bad baad. please use ActiveX, it's secure and nice!" (ok, the last part is irony on my part) fernando.cassia@gmail.com Java 0 04-16-2005 10:05 PM
The Jackal (1998) DTS vs non-DTS Aphelion DVD Video 2 04-07-2005 01:44 AM
Re: Matrix DTS and Matrix 2 DTS? PeterTHX DVD Video 0 08-03-2003 05:46 AM



Advertisments