r/PHPhelp • u/michawb • Aug 01 '25
Solved SOAP request is empty
Hello community,
I have to deal with the dreaded EU API, and unfortunately, they use a SOAP API.
Well – I always find that terrible, but what can you do.
In any case, I'm now facing the problem that the generated XML seems to be correct (a test via Postman worked as expected), but the response from the SoapClient in PHP is always empty. Even the request via ->__getLastRequest is empty.
Does anyone here have an idea?
$doc = new DOMDocument('1.0', 'UTF-8');
>/*SOME DOM-Generating-Code*/>
$client = new SoapClient($this->wsdl, [
'trace' => true,
'exceptions' => true,
'cache_wsdl' =>
WSDL_CACHE_NONE
]);
$request = $doc->saveXML();
$client->__doRequest(
$doc->saveXML(),
$this->url,
$action,
SOAP_1_1
);Request-Header-Output:
POST /tracesnt/ws/EudrEchoService HTTP/1.1
Host: acceptance.eudr.webcloud.ec.europa.eu
Connection: Keep-Alive
User-Agent: PHP-SOAP/7.4.33
Content-Type: text/xml; charset=utf-8
SOAPAction: "testEcho"
Content-Length: 1811getLastResponse Output: null
Response-Header-Output
HTTP/1.1 200 OK
Content-Length: 926
Content-Type: text/xml; charset=utf-8
Date: Fri, 01 Aug 2025 10:09:58 GMT
Server: European-Commission
Set-Cookie: cookie-sticky-cls=1754042999.733.653.787235|*****************; Expires=Fri, 01-Aug-25 11:09:58 GMT; Max-Age=3600; Path=/; Secure; HttpOnly
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Oracle-Dms-Ecid: eff030ea-55bc-4fc2-862a-02e5c9d5bca0-000dcea0
X-Oracle-Dms-Rid: 0getLastResponse Output: null
//EDIT:
However, when I send the request using a cURL call, I get the expected response.
View all comments
Show parent comment
4
u/Big_Tadpole7174 Aug 01 '25
Ah gotcha, the auth thing makes sense. For the WSSE header, you can actually still use the proper method calls - just set the header first:
That should give you both the auth and proper tracking of requests/responses.
For the SimpleXML thing - yeah that's just namespace nonsense. The response probably has a bunch of soap/xml namespaces that SimpleXML chokes on. Quick dirty fix:
Just strips out all the namespace declarations. Not elegant but gets the job done.