Также если заголовки не определены, я получаю пустой ответ.
Вот код, который я использовал:
Код: Выделить всё
try {
$data = $this->generateXml($get_last_day);
$client = new Client(['verify' => false ]);
$headers = [
'SOAPAction' => "https://api.xyz.com/DataService/PostData",
'Content-Type' => "text/xml"
];
$get_invoices_only_paid = $client->request('POST', config('constants.service.URL'), [
'headers' => $headers,
'body' => $data
]);
Log::debug(json_encode($get_invoices_only_paid->getStatusCode()));
dd($get_invoices_only_paid->getStatusCode());
} catch (Exception $e) {
dd($e->getCode(), $e->getMessage());
}
Код: Выделить всё
public function generateXml($date)
{
// $xml = new SimpleXMLElement(''.$date->format("Y-m-d").'');
$xml = new SimpleXMLElement('2024-04-15');
$customXML = new SimpleXMLElement($xml->asXML());
$dom = dom_import_simplexml($customXML);
$cleanXml = $dom->ownerDocument->saveXML($dom->ownerDocument->documentElement);
$soapHeader = 'usernamepassword';
$soapFooter = '';
$xmlRequest = $soapHeader . $cleanXml . $soapFooter;
return $xmlRequest;
}
Код: Выделить всё
500
"""
Server error: `POST https://services.as24.com:8445/infoservice/services/infoservice` resulted in a `500 500` response:\n
soap:Server
Подробнее здесь: [url]https://stackoverflow.com/questions/78815750/laravel-8-guzzle-soap-request-returns-error-500[/url]
Мобильная версия