This is working for me, sending a XML file with \Drupal::httpClient() POST
$endpoint = 'http://example.com/something';
$xml = '<>'; // You're XML here.
// Make the request.
$options = [
'connect_timeout' => 30,
'debug' => true,
'headers' => array(
'Content-Type' => 'text/xml',
),
'body' => $xml,
'verify'=>true,
];
try {
$client = \Drupal::httpClient();
$request = $client->request('POST',$endpoint,$options);
}
catch (RequestException $e){
// Log the error.
watchdog_exception('custom_modulename', $e);
}
$responseStatus = $request->getStatusCode();
$responseXml = $request->getBody()->getContents();
Hope this helps.
More info about Guzzle here: http://docs.guzzlephp.org/en/latest/index.html