Altova RaptorXML+XBRL Server 2024

The C# program code containing the jobs for RaptorXML+XBRL Server is defined in the C# file named Program.cs. The code uses the classes defined in the C# Wrapper for REST API to create the REST requests that are sent to RaptorXML+XBRL Server.

 

In the program code, there are three use cases to demonstrate how to use RaptorXML+XBRL Server's REST API :

 

Validation of a referenced XML file with RaptorXML+XBRL Server's valany command. The schema file is referenced from within the XML file and does not need to be provided as an argument of the command.

Two XML files are validated using RaptorXML+XBRL Server's valany command. Both XML files, as well as the schema file used for the validation, are uploaded with the command as string attachments. The result of the validations are returned together after both validations have completed.

An XML file is uploaded and transformed by an XSLT file. Both files are uploaded via REST. The command used is RaptorXML+XBRL Server's xslt. The document resulting from the transformation is retrieved by the program..

 

The code for these three use cases is discussed in more detail below.

 

Error handling

In the event that an error is returned, an error handler function (named HandleError) at the bottom of the code retrieves the error message from the server response.

 

Case 1: Validate a referenced XML file (simple command)

The program code for this case uses classes and functions from the REST API wrapper to set up and execute the HTTP communication with RaptorXML+XBRL Server. The logic of the code is as follows:

 

RaptorXMLRESTAPI.Command

Specifies the RaptorXML+XBRL Server command to call, which is valany, and the file to be submitted as the argument of the valany command.

RaptorXMLRESTAPI.CommandResponse

Puts the server's response to the validation request into the jsonResponse variable. Note that validation jobs are reported as "OK" or "Failed".

RaptorXMLRESTAPI.ResultDocument

Fetches the result document returned by the server and, if there are no errors, displays the validation result.

 

 

Case 2: Validate two uploaded XML files against an uploaded XSD (multipart command)

The program code for this case uses the MultiPartCommand class of the REST API wrapper to set up and execute the HTTP communication with RaptorXML+XBRL Server. Since we want to upload files within the body of the POST request, the message header must have its content type set to multipart/form-data. The wrapper's MultiPartCommand class is used to set up the REST HTTP communication accordingly. The code for this use case is organized as follows:

 

RaptorXMLRESTAPI.MultiPartCommand

Specifies the RaptorXML+XBRL Server command to call, which is valany, and then uses the AppendAttachment function of the class to upload the two XML files and the schema file. The files are submitted as strings. The server response returns the validation result of both files and this response is stored in the jsonResponse variable

RaptorXMLRESTAPI.fetchCommandResult

Fetches the result document returned by the server and, if there are no errors, displays the validation results.

RaptorXMLRESTAPI.cleanupResults

This function of the wrapper uses the DELETE method of HTTP to delete the result document file, temporary files, and error and output document files related to the job.

 

 

Case 3: XSLT transformation of uploaded XML and XSLT (multipart command)

The program code for this case is similar to that of Case 2 above. It uses the MultiPartCommand class to set up an XSLT transformation and display the result document in a message box. The XML and XSLT files for the transformation are uploaded with the request. Additionally, the XSLT command of RaptorXML+XBRL Server also takes options, so this case shows how you could add options via the REST interface (in the example, this is done with the RaptorXMLRESTAPI.AppendOption function. Important points about the code are given below.

 

RaptorXMLRESTAPI.MultiPartCommand

Specifies the RaptorXML+XBRL Server command to call, which is XSLT, and then uses (i) the AppendAttachment function of the class to upload the XML and XSLT files, and (ii) the AppendOption function to provide options for the RaptorXML+XBRL Server command line. The uploaded files are submitted as strings. The server response returns the validation result of both files and this response is stored in the jsonResponse variable

RaptorXMLRESTAPI.fetchCommandResult

Fetches the result document returned by the server and, if there are no errors, displays the validation results.

RaptorXMLRESTAPI.cleanupResults

This function of the wrapper uses the DELETE method of HTTP to clean up the result document file, temporary files, and error and output document files related to the job.

 

 

© 2018-2024 Altova GmbH