Jump to content

SOAP and AutoIT


Recommended Posts

Does anyone have any current, working examples of using AutoIT and working with SOAP/WSDL? I swear I have read EVERYTHING on these forums and tried various things I've found, even just basic basic basic examples... I can't get ANYTHING to work... ? What am I missing out on, I have a basic understanding of the SOAP, and I've been using AutoIT forever... so it's not for a lack of knowledge and I don't even ask for help all that often... I'm juts stumped.

Link to comment
Share on other sites

Here's an example of what I need to send... currently I'm using the SoapUI program and it works great, but now to get it into AutoIT.. ???

POST http://not.telling.net/UDSM_R11_WebService/mod_gsoap.dll HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
User-Agent: Jakarta Commons-HttpClient/3.1
Host: not.telling.net
Content-Length: 403

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:r11="urn://www.ca.com/Unicenter/DSM/r11">
   <soapenv:Header/>
   <soapenv:Body>
      <r11:Login>
         <r11:userName>winnt://nope/whatever</r11:userName>
         <r11:password>riiiiiight</r11:password>
         <r11:manager>not-telling</r11:manager>
      </r11:Login>
   </soapenv:Body>
</soapenv:Envelope>
Edited by GregThompson
Link to comment
Share on other sites

Download and install MS SOAP Toolkit (google it up).

Then try this:

Dim $SOAPClient
$SOAPClient = ObjCreate("MSSOAP.SOAPClient")

$SOAPClient.mssoapinit("http://www.webservicex.net/country.asmx?wsdl") 
If @error then
    ConsoleWrite($SOAPClient.faultString)
    ConsoleWrite($SOAPClient.detail)
Endif

Dim $cl = $SOAPClient.GetCountries()
$cl = StringReplace($cl, "&lt;" , "<")
$cl = StringReplace($cl, "&gt;" , ">")

Dim $f = FileOpen ("soap-response.xml", 2)
FileWrite($f, $cl)
FileClose($f)

Read toolkit documentation for further details.

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE 

Link to comment
Share on other sites

@GregThompson

This example in the first post is what you are looking for.

http://www.autoitscript.com/forum/index.php?showtopic=45904&st=0#entry342453

@Doudou

Your exmaple does not work, because it does not take care to the values returned.

Rgds,

ptrex

Link to comment
Share on other sites

@GregThompson

This example in the first post is what you are looking for.

http://www.autoitscript.com/forum/index.php?showtopic=45904&st=0#entry342453

Yeah, why simple if you can do complicated?!

Manually establishing SOAP session by fiddling with XML is the last thing you should do, if there is a library for exactly this purpose.

@Doudou

Your exmaple does not work, because it does not take care to the values returned.

Ah? What are you talking about? The sample may lack error handling but it is WORKING and a good start. Have you tried it out at all? Do so before bashing other people who try to help.

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE 

Link to comment
Share on other sites

  • 3 years later...

@ptrex,

Everytime I run the two lines of code below:

$SOAPClient = objcreate("MSSOAP.SOAPClient")
$SOAPClient.mssoapinit('https://api.betfair.com/global/v3/BFGlobalService.wsdl')

I receive an error on the 2nd line:

 ==> Variable must be of type "Object".

I guess the object  

The SOAP toolkit I downloaded and installed is from http://www.microsoft.com/en-gb/download/details.aspx?id=7043 .

I wonder if this is the same version you are using, and if you had to add anything to your classpath in order to get this to run from autoit?

I'm running WIndows 7 Home Premium, service pack 1 if that clarifies anything.

I you have any ideas to get this running I'd be very grateful

Adam

Link to comment
Share on other sites

Add a COM error handler for detailed error information. An example can be found in the help file for ObjEvent.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks for the fast response water.

 I read that the object with version 3.0 of MSSOAP should be called "MSSOAP.SoapClient30", so updated my code and added an error handler:

$oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

$SOAPClient = ObjCreate("MSSOAP.SoapClient30")


$SOAPClient.mssoapinit('http://localhost/Webservice/WS_HelloWorld.asmx?wsdl') 

#forceref $oErrorHandler, $oIEEvents


; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
   "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
   "err.description is: " & @TAB & $oError.description & @CRLF & _
   "err.source is: " & @TAB & $oError.source & @CRLF & _
   "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
   "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
   "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
   "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
   "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

the error returned is:

err.number is:  -2147221005
err.windescription: Invalid class string

err.description is:  
err.source is:  
err.helpfile is:  
err.helpcontext is:  15832000
err.lastdllerror is:  1008
err.scriptline is:  5
err.retcode is:  15834960

err.number is:  169
err.windescription: Variable must be of type 'Object'.
err.description is:  
err.source is:  
err.helpfile is:  
err.helpcontext is:  15832000
err.lastdllerror is:  0
err.scriptline is:  8
err.retcode is:  15834960

 

Thanks for taking a look

Adam

Link to comment
Share on other sites

Either installsation of the soap toolkit was not succesfull or the mname of the object is wrong.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 1 year later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...