Sign in to follow this  
Followers 0
Clay

Webservice Access

3 posts in this topic

Hey guys,

Quick Question: Has anyone ever tried using autoit to retireve data using webservies?

I am attempting to do with now. I am trying to access a webservice in order to return some data and manipulate it. Now I have never tried using webservices before and I am faily new to autoit so I am getting confused on two fronts. I have included a snippet of my code below where I am attempting to access the webserive... the result that is returned is 0 or -1 depending which web service I include in the http: path.....could someone please take a look at the code and let me know:

1). if I am missing anything or doing anything wrong in order to access the webservice - is my syntax off? is the script not suffient in order to accomplish what

I want?

2) Why I am getting a result of 0 or -1?

Note: The web service I am attempting to access does not use SOAP. Also in the snippet below I just included the path to a Microsoft web service... I can not provide the one I am actually trying to access as it contains sensitive data - I hope this does not offend anyone.

Dim $objHTTP 
Dim $objReturn
Dim $value
Dim $packageQueryUrl= "http://www.microsoft.com/technet/scriptcenter/default.mspx"


$objHTTP = ObjCreate("Microsoft.XMLHTTP")
$objReturn = ObjCreate("Msxml2.DOMdocument.3.0")

$objHTTP.Open("Get", $packageQueryUrl, False )
$objHTTP.Send

$value = $objReturn.loadXML($objHTTP.ResponseText)
MsgBox(0,"DevCentral Result equals: ", $value)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Ok....no one replied but thanks to all who atleast took a look. Fortunately I was able to solve my issue myself.... so I am just adding a reply to my initial post for the benefit of those who will run into this issue after me. I have included the code below that enabled me to retrieve information from the webservice.

1. Basically this was wrong. loadXML is not required

$value = $objReturn.loadXML($objHTTP.ResponseText)

2.An XMLHTTP Object is not required, but it doesn't hurt to keep it in.

Below you can find the corrected script

Dim $objHTTP 
Dim $objReturn
Dim $Result
Dim $packageQueryUrl= "http://www.microsoft.com/technet/scriptcenter/default.mspx"

$objHTTP = ObjCreate("Microsoft.XMLHTTP")
;$objReturn = ObjCreate("Msxml2.DOMdocument.3.0")

$objHTTP.Open("Get", $packageQueryUrl, False )
$objHTTP.Send

$Result = $objHTTP.ResponseText

MsgBox(0,"Result equals: ", $Result)

I hope this is helpful to someone in the future.

Peace !!!!!

Edited by Clay

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks! This is very useful. I've been looking for something exactly like this. I don't like trying to use TCP to send everything...

Replace the MsgBox() line with this code:

$File=FileOpen("Result.txt",2)
FileWrite($File,$Result)
FileClose($File)
ShellExecuteWait("notepad.exe","Result.txt")
FileDelete("Result.txt")

It makes it easier to view larger amounts of text + other things you can probably think of that are more useful than MsgBox()

Edited by NTARelix

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0