7 posts in this topic
Searching fields within XML
I have created an app that allows me to save server names as field values and other information associated with their nodes. (example below)
I am trying to use "_XMLNodeExists" from "_XMLDOMWrapper.au3" to search for existing server entries by field value. (Sorry if my XML terms are not quite right) I didn't quite follow how to search and I am not sure if this function can perform how I expect it to...
_XMLNodeExists('//Servers/ServerInfo/Server_Name/MyServerName')Any suggestions how I might go about searching my XML file? I had thought of just searching as plain text.
API Upload XML WinHttp
I'm trying to use Sendspace API for download and upload, until now i only have learned to get token, login and get session key. My next step is upload a file. But i have no idea how to do this part.
; try to upload something ; Specify the reguest to upload.getInfo: Local $hRequest = _WinHttpOpenRequest($hConnect, Default, "/rest/?method=upload.getinfo&session_key=" & $SessonKey & "&speed_limit=0") ; Send request Local $handle = _WinHttpSendRequest($hRequest) ; Wait for the response Local $WaitRS = _WinHttpReceiveResponse($hRequest) ; Read Data Local $sData = _WinHttpReadData($hRequest) MsgBox(0, "Upload Data", $sData) _filewrite($sData) ; Get all info needed from $sData $URL = _StringBetween($sData, "<upload url=", "progress") $sURL = $URL $MaxFileSize = _StringBetween($sData, "max_file_size=", "progress") $sMaxFileSize = $MaxFileSize $Upload_Identifier = _StringBetween($sData, "upload_identifier=", "&") $sUpload_Identifier = $Upload_Identifier $ExtraInfo = _StringBetween($sData, "extra_info=", "/>") $sExtraInfo = $ExtraInfo ;All well done until here ;Fill in form $XML = '<form method="post" action="' & $sURL & 'enctype="multipart/form-data">' & @CRLF $XML &= '<input type="hidden" name="MAX_FILE_SIZE" value=' & $sMaxFileSize & '>' & @CRLF $XML &= '<input type="hidden" name="UPLOAD_IDENTIFIER" value=' & $sUpload_Identifier & '>' & @CRLF $XML &= '<input type="hidden" name="extra_info" value=' & $sExtraInfo & '>' & @CRLF $XML &= '<input type="file" name=' & "C:\Users\Arlen\Desktop\premisa mrotal.txt" & '>' & @CRLF $XML &= '</form>' MsgBox(0,"", $XML) ; Now how do i send it? Is it correct? _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)
Idea: Feature Rich REST UDF
There are some impressive UDFs emerging or being re-written recently surrounding REST services. At the same time, the explosion of useful web services and use-cases to tie them together shows no signs of slowing. I suggest a project to tie together the existing UDFs into a more comprehensive UDF which abstracts the four major functions of working with REST services:
Authentication (OAuth1/2, OpenID/Connect, Etc) The HTTP Calls (Flexibility with URL, HTTP Methods, Header, Body) Manipulating the Data (XML and JSON) Local Storage/Caching (A new file-based NoSQL Strategy combined with SQLite) Some of these are pretty tall orders, however the overall notion seems so universally useful with the present technologies, I wanted to suggest it for community feedback to measure support.
Full disclosure, I don't have time or skill level to contribute to these UDF's in a meaningful way. I thought maybe I shouldn't even post this for that reason, but I went ahead anyway.
The UDFs that I find exciting and think would be good candidates for inclusion are listed below:
REST API - Post XML data with HTTP
I'm in the making of a script that needs to post XML data through HTTPS to our ServiceDesk Plus MSP service. I'm running into trouble because I have never made any scripts using HTTP with POST and I cannot see what I'm doing wrong here.
Can someone help me or should I find help somewhere else?
$URLSDP="" ;REMOVED - cannot publish this. this is the HTTPS url to our ServiceDesk $TechnicianKey="" ;REMOVED $ID="" ; Request ID $sPostData = "OPERATION_NAME=ADD_NOTE&INPUT_DATA=<Operation><Details><Notes><Note><isPublic>false</isPublic><notesText>Text added to the note</notesText></Note></Notes></Details></Operation>&format=XML" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", $URLSDP & "/sdpapi/request/"& $ID & "/note?TECHNICIAN_KEY="& $TechnicianKey, False) $oHTTP.SetRequestHeader("Content-Type", "xml") $oHTTP.Send($sPostData) $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status ConsoleWrite($oStatusCode & @CRLF) ConsoleWrite($oReceived & @CRLF) If $oStatusCode = 200 Then ;Process the response $oReceived ;ConsoleWrite(@CRLF & "Response" & @CRLF & $oReceived & @CRLF) Else MsgBox(16, "Error " & $oStatusCode, $oReceived, 7) EndIf Response:
<operation name="POST"><result><status>Failed</status><message>Invalid operation</message></result></operation>REST API guide.
XMLWrapperEx.au3 - BETA
I was asking @eltorro serveral times for any support for XML DOM wrapper (COM) - with no success
So I took matters into my hands .....I want to present XMLWrapperEx.au3 - BETA Version
Want to join to the project ?
Here is some description:
; #INDEX# ======================================================================================================================= ; Title .........: XMLWrapperEx.au3 ; AutoIt Version : 220.127.116.11++ ; Language ......: English ; Description ...: Functions to use for reading and writing XML using msxml. ; Remarks .......: BETA Version ; Author ........: mLipok ; Version .......: "1.1.1.01" ; _XML_MiscProperty_UDFVersion() #CS This UDF is created on the basis of: https://www.autoitscript.com/forum/topic/19848-xml-dom-wrapper-com/ For this reason, I attach also the last known (to me) previous version ($_XMLUDFVER = "18.104.22.168" _XMLDomWrapper_22.214.171.124_CN.au3 ) For the same reason I continue to recognize the achievements of the work of my predecessors (they are still noted in each Function header). . . . . !!!!!!!!! This is BETA VERSION (all could be changed) !!!!!!!!! . . . WORK IN PROGRES INFORMATION: For now 2015-09-01 the descripion (Function Header) can not entirely correctly describe the function. TODO: in many places I used "TODO" as a keyword to find what should be done in future . I want to: PREVENT THIS: The unfortunate nature of both the scripts is that the func return results are strings or arrays instead of objects. . I want to: USE THIS CONCEPT: . All function should use Refernce to the object as first Function parameter . All function should return in most cases objects. There should be separate functions to Change Object collection to array . All function should use COM Error Handler in local scope. . All function should return @error which are defined in #Region XMLWrapperEx.au3 - @ERROR Enums . All function should have the same naming convention . All variables should have the same naming convention . There should not to be any Global Variable - exception is $g__oXMLDOM_Events . It should be possible easy to use XML DOM Events . https://msdn.microsoft.com/en-us/library/ms764697(v=vs.85).aspx . It should be possible easy to Debug . Ultimately, you should be able to do anything with your XML without having to use your own Error Handler. #CE
More info inside zip archive.
This UDF can be downloaded from here: