Test with CURL
The third-party application CURL (http://curl.haxx.se/) is a command line utility that you can use to test the POST request. CURL provides a very useful trace option that generates and lists the part boundaries of requests, which you can use directly in your requests or as a reference.
Given below is a sample test scenario in which an XML file is validated against an XML Schema. We assume the following:
•the commands below are executed from the folder in which the files to be submitted for validation are located; (this enables us to write simple relative paths to these files). If you have installed Altova's XMLSpy application, the files used in this example can be found in the application's Examples folder, which is located by default at: C:\Users\<username>\Documents\Altova\XMLSpy2025\Examples
•RaptorXML+XBRL Server is running locally on port 8087
For more information about the CURL command line options, see the CURL Help.
Call CURL with the validation command on Windows
[input: powershell]
\path\to\curl.exe -F 'msg={\"command\": \"xsi\", \"args\":[\"additional-files:///PurchaseOrder.zip%7Czip/ipo.xml\"], \"options\":{}};type=application/json' -F "additional-files=@PurchaseOrder.zip;type=application/octet-stream" http://localhost:8087/v1/queue
Note: | In powershell, if quotes occur within quotes, different types of quotes (single/double) must be used. |
[input: cmd]
\path\to\curl.exe -F "msg={\"command\": \"xsi\", \"args\":[\"additional-files:///PurchaseOrder.zip%7Czip/ipo.xml\"], \"options\":{}};type=application/json" -F "additional-files=@PurchaseOrder.zip;type=application/octet-stream" http://localhost:8087/v1/queue
[output]
{"jobid": "058F9E97-CB95-43EF-AC0A-496CD3AC43A3", "result": "/v1/results/058F9E97-CB95-43EF-AC0A-496CD3AC43A3"}
Use the URL of "result" to fetch the result
[input]
\path\to\curl.exe http://localhost:8087/v1/results/058F9E97-CB95-43EF-AC0A-496CD3AC43A3
[output]
{"jobid":"058F9E97-CB95-43EF-AC0A-496CD3AC43A3","state":"OK","error":{},"jobs":[{"file":"additional-files:///PurchaseOrder.zip%7Czip/ipo.xml","jobid":"D4B91CB0-CF03-4D29-B563-B6506E123A06","output":{},"state":"OK","error":{}}]}
CURL's trace option
CURL has a trace option (--trace-ascii), which traces the HTTP traffic sent to and from the server. The option is very useful since it lists the part boundaries that are required for initiating jobs with POST. You can use the information in the trace, either directly or as a reference, to create the part boundaries. The listing below shows the trace obtained by running the command given above.
== Info: Trying ::1... == Info: Connected to localhost (::1) port 8087 (#0) => Send header, 217 bytes (0xd9) 0000: POST /v1/queue HTTP/1.1 0019: Host: localhost:8087 002f: User-Agent: curl/7.42.1 0048: Accept: */* 0055: Content-Length: 2939 006b: Expect: 100-continue 0081: Content-Type: multipart/form-data; boundary=-------------------- 00c1: ----d887ed58324015c3 00d7: <= Recv header, 23 bytes (0x17) 0000: HTTP/1.1 100 Continue => Send data, 393 bytes (0x189) 0000: --------------------------d887ed58324015c3 002c: Content-Disposition: form-data; name="msg" 0058: Content-Type: application/json 0078: 007a: {"command": "xsi", "args":["additional-files:///PurchaseOrder.zi 00ba: p%7Czip/ipo.xml"], "options":{}} 00dc: --------------------------d887ed58324015c3 0108: Content-Disposition: form-data; name="additional-files"; filenam 0148: e="PurchaseOrder.zip" 015f: Content-Type: application/octet-stream 0187: => Send data, 2498 bytes (0x9c2) 0000: PK........"..6}.c.....M.......ipo.xsd.T.N.@.}N....O 5v.}..S....( 0040: .JU/...$Y..5{.E......I*...g...Y...\....Z..~......P.A.ct....y. ... 0940: .........."..6]g......l............. .......address.xsdPK....... 0980: ..."..6I..v.................. .......ipo.xmlPK.................. 09c0: .. => Send data, 48 bytes (0x30) 0000: 0002: --------------------------d887ed58324015c3-- <= Recv header, 22 bytes (0x16) 0000: HTTP/1.1 201 Created <= Recv header, 13 bytes (0xd) 0000: Allow: POST <= Recv header, 32 bytes (0x20) 0000: Content-Type: application/json <= Recv header, 37 bytes (0x25) 0000: Date: Fri, 24 Jul 2015 16:58:08 GMT <= Recv header, 24 bytes (0x18) 0000: Server: CherryPy/3.6.0 <= Recv header, 21 bytes (0x15) 0000: Content-Length: 111 <= Recv header, 2 bytes (0x2) 0000: <= Recv data, 111 bytes (0x6f) 0000: {"jobid": "058F9E97-CB95-43EF-AC0A-496CD3AC43A3", "result": "/v1 0040: /results/058F9E97-CB95-43EF-AC0A-496CD3AC43A3"} == Info: Connection #0 to host localhost left intact
|
Note: | Notice from the above listing that 'Content-Disposition: form-data' is also valid, in addition to 'Content-Disposition: attachment'. |
Call CURL with the well-formed-check command on Linux
/path/to/curl -F 'msg={"command": "wfxml", "args":[]};type=application/json' -F "args=@ipo.xml;type=application/octet-stream" http://localhost:8087/v1/queue
/path/to/curl -F 'msg={"command": "wfxml", "args":["additional-files:///ipo.zip%7Czip/ipo.xml"]};type=application/json' -F "additional-files=@ipo.zip;type=application/octet-stream" http://localhost:8087/v1/queue