[solved] SOAP return with 500 Error

Hello guys,

i want to implement SOAP in my Slim Application. I have a local server where i can get the WSDL.

When i try to submit the URL (http://local.uri.de/api/soap?wsdl=1) via postman, everything works fine an it returns the SOAP schema. Started with:

<?xml version="1.0" encoding="UTF-8"?>

In my application i use SoapClient, and i add the URL and some parameters.

$soapOptions = array(
      'soap_version' => SOAP_1_2,
      'trace' => true,
      'exceptions' => true,
      'cache_wsdl' => WSDL_CACHE_NONE,
      'features' => SOAP_SINGLE_ELEMENT_ARRAYS

so it looks like:

new SoapClient($url, $soapOptions);

The Reponse i become is an 500 Error.
“statusCode”: 500,
“error”: {
“type”: “SERVER_ERROR”,
“description”: "SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘http://local.uri.de/api/soap?wsdl=1’ : failed to load external entity "http://local.uri.de/api/soap?wsdl=1"\n"

I checked SOAP and it was enabled.

Has anyone an idea why WSDL not work? Is there any important CORS settings or server settings?

I try the tool SoapUI and everything works like a charme. So the url is valid. But by using SoapClient in PHP the error above occur.

The SoapClient in PHP is a broken tool. Have you tried to send a custom generated XML request using Guzzle as HTTP client?

Hello Odan,

thank for the advice! I’m not try Guzzle so far.

Can you make an example for your answer?

I’m not familiar with SOAP and i want to consume the xml file, e.g. at the end i want send data via SOAP

You can find the details in the Guzzle docs.

This is just a very basic example to show the concept:

use GuzzleHttp\Client;

$client = new Client(
        'base_uri' => 'https://httpbin.org/',
        'cookies' => false,
        'headers' => [
            'Accept' => 'text/xml; charset=UTF-8',
            'Content-Type' => 'text/xml; charset=UTF-8',
            'User-Agent' => 'SoapHttpClient/1.0',

// The SOAP content
$xmlBody = '<?xml version="1.0"?><soap:Envelope></soap:Envelope>';

// Send a request
$response = $client->request('POST', 'anything', ['body' => $xmlBody]);

$xmlContent = (string)$response->getBody();

$dom = new DOMDocument('1.0', 'utf-8');

// Query the DOM with XPath
$xpath = new DOMXpath($dom);
// ...

I tried your code snippet and check the guzzle docs. i always get back a 500 error. with this error message

    "statusCode": 500,
    "error": {
        "type": "SERVER_ERROR",
        "description": "Client error: `POST http://local.uri.de/api/v2_soap` resulted in a `404 Not Found` response:\n{\n    \"statusCode\": 404,\n    \"error\": {\n        \"type\": \"RESOURCE_NOT_FOUND\",\n        \"description\": \"Not found.\"\n    }\n (truncated...)\n"

in postman i see a message for the certifate “Unable to verify the first certificate”… i run my slim application in a docker ddev container… mkcert is insert but i’m not sure if this enough

it look like a missing server configuration, but i’m not sure. in postman if i try the direct route to wsdl it works

For development purpose only it’s ok to ignore invalid SSL certificates:

'verify' => false

Please consult the Guzzle documentation for more details.

http://local.uri.de/api/v2_soap resulted in a404 Not Found`

This looks like an 404 not found error. So you have to check the URL again.

hey odan, thanks for the advice! ssl was not required anymore.

in the meanwhile i found a solution.

on my data server i have to add a RewriteRule to enable API calls.

Now it works with Guzzle and SoapClient as well!

1 Like

Just to add another alternative for somebody who could need it.
I have to create a SOAP client to interact with a SAP service and finalised it using “econea/nusoap”: “^0.9.6” in my composer file.
This is a adaptation for the old nusoap class but it works pretty wood inside my slim3 app under php 7.x