M
M
Max Cohen2018-09-03 13:24:13
PHP
Max Cohen, 2018-09-03 13:24:13

SoapClient::__doRequest() returned non string value... what's wrong?

Good afternoon,

I wrote a simple PHP script that uses the SOAP service to send a request to the server. The server accepts the request and then responds. The problem is here, I can't read anything from the response:

Error message:
SoapClient::__doRequest() returned non string value

Header response is like this:

HTTP/1.1 200 OK
Date: Mon, 03 Sep 2018 10:17:16 GMT
Content-Length: 1352
Content-Type: text/xml; charset=utf-8
X-Powered-By: Servlet/2.5 JSP/2.1


PHP version:
7.0.31.

PHP code:
<?php

ini_set('display_errors', TRUE);
ini_Set('display_startup_errors', TRUE);

ini_set('soap.wsdl_cache_enabled', 1);
ini_set('soap.wsdl_cache_ttl', 0);

$url = '... URL to WSDL ...';

$client = new SoapClient($url, array(
    'connection_timeout' => 50,
    'cache_wsdl' => WSDL_CACHE_MEMORY,
    'trace' => 1,
    'soap_version' => 'SOAP 1.2',
    'encoding' => 'utf-8',
    'exceptions' => true,
    'login' => '...username...',
    'password' => '...password...',
));

class TestClass
{
    public $testVar;
}

$test = new TestClass;
$test->testVar = 'TestTestTest';

try {
    $return = $client->__soapCall('TestFunction', array($test));
} catch (SoapFault $soapFault) {
    print_r($soapFault->getMessage());

    echo "Request: ", htmlentities($client->__getLastRequest());
    echo "Response: [", htmlentities($client->__getLastResponse());

    print_r($client->__getLastRequest());
    print_r($client->__getLastRequestHeaders());
    print_r($client->__getLastResponse());
    print_r($client->__getLastResponseHeaders());
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question