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
2
u/michawb Aug 05 '25
Hey,
After a lot of testing and problems with the namespaces and especially the prefixes (<S:BODY> etc.) I have now built the following small function that solves the problem with the namespaces differently - maybe someone else can use it
Here the XML-Test
The function
and the output: