- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 06-17-2022 09:38 AM
Per the ServiceNow documentation, it is possible to create "Custom Parsing Strategies" for use in developing discovery patterns when one of the many standard strategies do not work for a given payload.
https://docs.servicenow.com/bundle/sandiego-it-operations-management/page/product/service-mapping/task/customize_parsing_strategies.html
In the process of developing such a custom parser, you may encounter the following kind of error message:
SEVERE *** ERROR *** (35)CustomParsingStrategy - parsing input has failure, trying to attempt with prefeix <Root>
SEVERE *** ERROR *** Can not parse content com.snc.sw.exception.FileParsingException: Failed to parse XML file. Error: Problem with File Structure
This would seem to intimate that the parsed output is not valid XML (a requirement, per the documentation). However, it can also be calling out a mismatch between the parser output and the parsing options populated in the pattern step. I'll try to show you what I mean.
I'll start by creation a very simple example custom parsing strategy, which kicks back a static, valid XML string:
*
* Custom Parsing Strategies are defined to be used in the definition of patterns. The script can use the the vaiable "content" that has the data passed through the operation that utilizes the strategy.
*
*
* Add your code here
* content = decodeURIComponent(content);
* rtrn = content
*
*
* Following the running of the script the returned value will be available as temporary variables in the pattern designer.
*
*/
rtrn = "<root><zone><name>excludezone01</name><type>forwarder</type></zone></root>";
Next, I'll go into Pattern Designer and create a test pattern which will populate a test variable and then parse it via the above parsing strategy.
When I try and test this simple setup with a single parsing option of "Name" on the right, I get the dreaded error:
It turns out this isn't a problem with the XML coming out of my parsing strategy, but the fact that it doesn't align with the specified parsing options. The way to fix this is ensure that there is a parsing option for every key included in the payload from the parsing strategy, for example:
Now when I test my pattern, it successfully parses the XML.