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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.