rajibgaru Posted October 12, 2010 Share Posted October 12, 2010 Hi , I am getting issues in posting a SOAP XML and getting/displaying the response back , here is the piece of code that i am trying to use $xmlhttp = ObjCreate("Microsoft.XMLHTTP") $oXML = ObjCreate("Msxml2.DOMdocument.3.0") $XmlSourceDO="..\BEAST_DASHBOARD\ActivationReq.xml" $oXML.load ($XmlSourceDO) $xmlhttp.open ("post","https://IP:Port/services/CAPWsController",false) $xmlhttp.setRequestHeader ("Content-type", "application/x-www-form-urlencoded; charset=UTF-8") $xmlhttp.setRequestHeader ("Content-length", StringLen($oXML.xml)) $xmlhttp.setRequestHeader ("Connection", "close") $xmlhttp.setRequestHeader ("SOAPMethodName", "processRequest") $xmlhttp.send($oXML.xml)-----> gives an error in this line If($xmlhttp.readyState = 4) then $XMLResponse = $xmlhttp.responseXML.documentElement.text $XMLResponse= $xmlhttp.responseText EndIf MsgBox(1,"asddf",$XMLResponse) I have ighlightted the line where i get the error , any help is highly appreciated. Thanks, Rajib Link to comment Share on other sites More sharing options...
rajibgaru Posted October 12, 2010 Author Share Posted October 12, 2010 Any help is highly appreciated...Auto It Gurus please help.... Link to comment Share on other sites More sharing options...
daluu Posted October 13, 2010 Share Posted October 13, 2010 What is the error message that is returned? Link to comment Share on other sites More sharing options...
rajibgaru Posted October 13, 2010 Author Share Posted October 13, 2010 Thank YOu for your reply , plese find the error message that i recieve :- --------------------------- AutoIt Error --------------------------- Line 85 (File "C:\BEAST_DASHBOARD\Tmob_SimChecker_Ver1.0.au3"): $xmlhttp.send ($oXML.xml) $xmlhttp.send ($oXML.xml)^ ERROR Error: The requested action with this object has failed. --------------------------- OK --------------------------- Link to comment Share on other sites More sharing options...
daluu Posted October 14, 2010 Share Posted October 14, 2010 (edited) Since you are using COM related code here, and the error is not from AutoIt but the COM code, suggest you try the equivalent code using VBScript instead. VBScript is designed for COM, so you can determine if the issue is with how you call/use the COM object, or if the issue is with AutoIt's COM interface. FYI, AutoIt's COM support isn't as good as VBScript. Hopefully, you have some familiarity with VBScript. It's similar to AutoIt. Dim xmlhttp, oXML Set xmlhttp = WScript.CreateObject("Microsoft.XMLHTTP") Set oXML = WScript.CreateObject("Msxml2.DOMdocument.3.0") '...more code here xmlhttp.send(oXML.xml) 'or xmlhttp.send oXML.xml Then run the code via command line as "cscript testScript.vbs" If you get error still in VBScript, then you know that your COM call is incorrect where you get the error. Otherwise, either the AutoIt COM call is incorrect, and the syntax is to be written differently, or AutoIt doesn't support that particular COM object method call unfortunately. Edited October 14, 2010 by daluu Link to comment Share on other sites More sharing options...
rajibgaru Posted October 15, 2010 Author Share Posted October 15, 2010 In Vbscript it works fine. I was trying to find the equivalent AutoIt code for it . Link to comment Share on other sites More sharing options...
daluu Posted October 15, 2010 Share Posted October 15, 2010 (edited) Guess AutoIt syntax is different, or that particular case won't work in AutoIt. Unfortunately, AutoIt is not a first class citizen as a COM client. Quite a few COM things that work under VB/VBScript won't under AutoIt, at last not w/o hours spent debugging to get the "right" syntax. Can you convert the XML to plain text and send that? Maybe AutoIt not like the XML object. Another thing you can try, is to set XmlHttp to another URL, which is some custom web service (or script) to do debug processing (e.g. echo back what you send it as a response). Then from there, try $xmlhttp.send($oXML.xml), $xmlhttp.send (""), $xmlhttp.send ("some text"), $xmlhttp.send ($stringVar). That at least will tell you if the problem is with the $xmlhttp.send() or with $oXML.xml, so I think. And also try to print out $oXML.xml to be sure that works OK too. Edited October 15, 2010 by daluu Link to comment Share on other sites More sharing options...
doudou Posted November 3, 2010 Share Posted November 3, 2010 I am getting issues in posting a SOAP XML and getting/displaying the response back , here is the piece of code that i am trying to use Try this: $xmlhttp = ObjCreate("Microsoft.XMLHTTP") $oXML = ObjCreate("Msxml2.DOMdocument.3.0") $oXML.async = False ; ---^ without this chances are good your xml haven't been parsed yet when you attempt to send it $XmlSourceDO="..\BEAST_DASHBOARD\ActivationReq.xml" $oXML.load ($XmlSourceDO) $xmlhttp.open ("post","https://IP:Port/services/CAPWsController",false) $xmlhttp.setRequestHeader ("Content-type", "application/x-www-form-urlencoded; charset=UTF-8") $xmlhttp.setRequestHeader ("Content-length", StringLen($oXML.xml)) $xmlhttp.setRequestHeader ("Connection", "close") $xmlhttp.setRequestHeader ("SOAPMethodName", "processRequest") $xmlhttp.send($oXML.xml)-----> gives an error in this line If($xmlhttp.readyState = 4) then $XMLResponse = $xmlhttp.responseXML.documentElement.text $XMLResponse= $xmlhttp.responseText EndIf MsgBox(1,"asddf",$XMLResponse) UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE Link to comment Share on other sites More sharing options...
PatrickMc Posted December 4, 2010 Share Posted December 4, 2010 If you absolutely do not want to use vbscript, here is one way to do it using biterscripting. # Start an internet session and connect it to server at https://IP:Port isstart "session1" "SOAP/XML Interface" "Mozilla/4.0" iscon "session1" "https://IP:Port" > null # Set the header for the SOAP request. isheadsub "session1" "Content-type: application/x-www-form-urlencoded; charset=UTF-8" > null isheadsub "session1" "SOAPAction: \"https://IP:Port/services/CAPWsController\"" > null isheadsub "session1" "SOAPMethodName: processRequest" > null # Read in the input xml into a string variable. var str xml, out cat "..\BEAST_DASHBOARD\ActivationReq.xml" > $xml # Set the length of input xml in header. isheadsub "session1" ("Content-Length: "+{chen -n $xml})> null # Post the SOAP request to server. ispost -w "session1" "/services/CAPWsController" ($xml1) > $out echo $out # SOAP Response is in string variable $out (also printed to screen for visual). # Process it from there. # End connection to server and close session. isdiscon "session1" ; isend "session1" Check the documentation for isstart, isend, ispost, etc. commands here - http://www.biterscripting.com/helppages_automatedinternet.html . Link to comment Share on other sites More sharing options...
Zedna Posted December 5, 2010 Share Posted December 5, 2010 Add COM error handler to your script so it will display all the detailed errors for you. $objErr = ObjEvent("AutoIt.Error","MyErrFunc") Func MyErrFunc() MsgBox(16, "CHYBA", "Při COM došlo k chybě!" & @CRLF & @CRLF & _ "Popis chyby: " & @TAB & $oIEErrorHandler.description & @CRLF & _ "Win. popis:" & @TAB & $oIEErrorHandler.windescription & @CRLF & _ "Číslo řádku: " & @TAB & $oIEErrorHandler.scriptline & @CRLF & _ "Číslo chyby: " & @TAB & Hex($oIEErrorHandler.number, 8) & @CRLF & _ "Objekt: " & @TAB & $oIEErrorHandler.source) SetError(1) EndFunc Also try to use absolute path to XML file. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted December 5, 2010 Share Posted December 5, 2010 Since you are using COM related code here, and the error is not from AutoIt but the COM code, suggest you try the equivalent code using VBScript instead. VBScript is designed for COM, so you can determine if the issue is with how you call/use the COM object, or if the issue is with AutoIt's COM interface.FYI, AutoIt's COM support isn't as good as VBScript.You are wrong here. COM functionality is in Autoit implemented very well.He is using it just incorrectly.If you don't understand these things then please don't make these quick bad assumptions next time. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now