kay_koll_automic

HowTo: Webservice Agent 3.x - Modififing the REQUEST input parameter at runtime

Discussion created by kay_koll_automic on Oct 29, 2013
In case a web service request/input parameter is defined as a list values. The Automic Agent UI allows to predefine a fixed number of values for the list but sometimes it is necessary to specify the number of list items at runtime.  I had to deal with a large complex data type which size depends on runtime parameters. Web service Agent version 3.x expects input parameters as an XML encoded structure. This structure can be replaced with other XML structures at runtime. Actually it is pretty easy. I have added following code snipped to the 'Pre-Script' tab.
:SET &ID# = 42 :SET &XML_1# = "<?xml version=""1.0"" encoding=""UTF-8""?>&ID#" :SET &XML_2# = "" :SET &XML_3# = "" :IF STR_LENGTH(&XML_1#) > 0 :  PUT_ATT sreq0 = &XML_1# :ENDIF :IF STR_LENGTH(&XML_2#) > 0 :  PUT_ATT sreq1 = &XML_2# :ENDIF :IF STR_LENGTH(&XML_3#) > 0 :  PUT_ATT sreq2 = &XML_3# :ENDIF
Due to the size limitation of 1024 characters of Automic variables I have defined three variables. Larger XML structure has to split to chunks of 1024 characters max.  Eventually you have to encode of special characters such as ‘&’ and you have to replace ‘ “ ‘ with ‘ ”” ’.  Following Wikipedia page for more details. en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references The XML option of the Agent UI allows to you to display request parameter as XML encoded structure. Thanks to Steve for the pointer

Outcomes