in reply to Encoding horridness

We don't know what your service provide considers "valid xml." Just for fun, what happens if you try this?
use Encode qw( encode XMLCREF ); print XML encode('ascii', $cureq, XMLCREF);