Example-1 (with Callouts): Validate XML
Given below is a listing of the body of a POST request. It has numbered callouts that are explained below. The command submitted in the listing request would have the following CLI equivalent:
raptorxml xsi First.xml Second.xml --xsd=Demo.xsd
The request is for the validation of two XML files according to a schema. The body of the request would look something like this, assuming that ---PartBoundary has been specified in the header as the boundary string (see Request Header above).
-----PartBoundary Content-Disposition: form-data; name="msg" Content-Type: application/json
| 1 |
{"command": "xsi", "options": {} , "args": []}
| 2 |
-----PartBoundary Content-Disposition: attachment; filename="First.xml"; name="args" Content-Type: application/octet-stream
| 3 |
<?xml version="1.0" encoding="UTF-8"?> <test xsi:noNamespaceSchemaLocation="Demo.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">42</test>
| 4 |
-----PartBoundary Content-Disposition: attachment; filename="Second.xml"; name="args" Content-Type: application/octet-stream
| 5 |
<?xml version="1.0" encoding="UTF-8"?> <test xsi:noNamespaceSchemaLocation="Demo.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">35</test>
| 6 |
-----PartBoundary Content-Disposition: attachment; filename="Demo.xsd"; name="additional-files" Content-Type: application/octet-stream
| 7 |
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="test" type="xs:int"/> </xs:schema>
| 8 |
-----PartBoundary-- | 9 |
1 | The name of the main form-data part boundaries are declared in the request header. The part boundary separator must be a unique string that will not occur anywhere in the embedded documents. It is prefixed with two dashes and is used to separate the multiple parts. The first form-data part in this example is msg. Note that the content type is application/json. |
2 | This is the standard syntax for HTTP POST requests. If args contains a reference to a file and if additional files are uploaded, both sets of files will be passed to the server. |
3 | The first member of the args array is a file attachment called First.xml. |
4 | The text of the file First.xml. It contains a reference to a schema called Demo.xsd, which will also be uploaded—in the additional-files form-data part. |
5 | The second member of the args array is an attachment called Second.xml. |
6 | The text of the file Second.xml. It too contains a reference to the schema Demo.xsd. See callout 7. |
7 | The first additional files part contains the Demo.xsd attachment metadata. |
8 | The text of the file Demo.xsd. |
9 | The end of the Demo.xsd additional files part, and the additional-files form-data part. Note that the last part boundary separator is both prefixed and postfixed with two dashes. |