The server doing the POST expects XML back but I keep getting errors about "protocol violation".
You may want to trace a good request and a failing request with Wireshark and see where the differences lie. I don't know if this is related, but when I run the XML from your post through xmllint it complains about the entity in the payloadID, if I change that to a regular @ it doesn't complain. Anyway, here's an example with Mojolicious::Lite:
#!/usr/bin/env perl use Mojolicious::Lite -signatures; use Mojo::DOM; # in case you need to parse the incoming XML sub TimeStamp { scalar gmtime } # dummy post '/toMFF' => sub ($c) { my $body = $c->req->body; my $dom = Mojo::DOM->new->xml(1)->parse($body); # example say "[[[$dom]]]"; # just for debugging $c->render('test', format => 'xml', timestamp => TimeStamp=~s/\s/T/r); }; app->start; __DATA__ @@ test.xml.ep <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.1.009/cXML.d +td"> <cXML payloadID="foo@ceprinter.com" xml:lang="en-US" timestamp="<%= $t +imestamp %>"> <Response> <Status code="200" text="OK" /> </Response> </cXML>
Run this via morbo test.pl, I sent a test request via curl -X POST http://127.0.0.1:3000/toMFF -H "Content-Type: application/xml" -d "<foo><bar/></foo>" (I of course don't know if this is representative of your real-world requests), and I get the following response:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.1.009/cXML.d +td"> <cXML payloadID="foo@ceprinter.com" xml:lang="en-US" timestamp="WedTJu +n 8 16:20:00 2022"> <Response> <Status code="200" text="OK" /> </Response> </cXML>
In reply to Re: Simple web server to ingest POST
by haukex
in thread Simple web server to ingest POST
by 23skiddoo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |