Send XML content from PHP with POST

This PHP snippet allows you to send an XML string to a SOAP endpoint.

This isn’t the only way but it’s the one I prefer.

$xml = '....your_xml_string....';
$send_context = stream_context_create(array(
    'http' => array(
    'method' => 'POST',
    'header' => 'Content-Type: application/xml',
    'content' => $xml
$url = '';
$result = file_get_contents($url, false, $send_context);

Senior Full-stack Developer. Self-taught programmer since I was 11yo. Chemical Engineer specialized in Waste Water Bio-treatment and Process simulation and modeling. Major Geek.