I have a rather nitpicky SoapApi that I want to talk to.
I need to change the SoapAction
header that is sent with the HTTP request.
I am not talking about \SoapHeader
that is passed along with the Soap Envelop as part of the XML message, but the HTTP header SOAPAction
.
Using curl I would send the request like this:
curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction: http://tempuri.org/my-custom-action" --data @message.xml http://some-soap-endpoint.asmx --proxy le-proxy:3218
It seems one can only set the SoapAction during SoapClient
creation
I stopped using \SoapClient
and for this particular "Soap" API (for a different reason as well) used Guzzle instead simply mimicking the curl request.
There, I fired a simple post request with raw XML against the API, and now it is working; even though I think it's a downside of not being able to use the dedicated \SoapService
.
If one wonders how to send a XML requests via guzzle, one can do:
$options = [
'body' => $body,
'headers' => [
"Content-Type" => "text/xml; charset=utf-8",
'SOAPAction' => 'tempuri.org/my-custom-action',
],
'proxy' => 'tcp://le-proxy:3128',
];
$client = new Client();
$soapRequest = $client->createRequest(
'post',
"http://some-soap-endpoint.asmx",
$options
);
try {
$response = $client->send($soapRequest);
} catch (RequestException $e) {
/**
* error handling
*/
}
I consider this a workaround though.