The Java server in question is SignServer. When I send a get request to /signserver/process
with processType
= signDocument
, it works. However, when I send with processType
= validateDocument
, the server responds with:
Received request wasn't an expected GenericSignRequest
If we look in PDFSigner.java on line 207 we see that exception is thrown if !(signRequest instanceof GenericSignRequest)
. A GenericSignRequest
is made via parsing, as seen in GenericSignRequest.java. If we look in GenericProcessServlet.java we see that at some point the processType
is turned in to an ISO-8859-1 string (processTypeAttribute = item.getString("ISO-8859-1")
) and then in to an enum (ProcessType.valueOf(processTypeAttribute)
).
That process relies on intricacies of the Java language, and I'm writing in JavaScript. I believe this is the reason for the error.
Here's how I send a request to SignServer:
var formdata = require('form-data');
var form = new formdata();
form.append('workerName', 'PDFSigner');
form.append('processType', 'validateDocument');
form.append('data', file_buffer, { filename: 'document.pdf });
var request = form.submit('http://localhost:8080/signserver/process', function(err, res) {});
I tried setting form
s headers charset
to 'utf-8'
, I also tried 'ISO-8859-1'
. It did not work.
I tried sending processType
as a buffer instead of a string, and it didn't work either.
(The same code works perfectly if processType
is 'signDocument'
- it successfuly sends a pdf and receives a signed pdf)
via Ivan Rubinson
No comments:
Post a Comment