SOAP CLIENTE | “看起来我们没有XML文档”| PHP 7

I already search everywhere, but can't find any solution to my problem.

I'm trying to connect to an API, but i'm getting this error "looks like we got no XML document".

I send an email to the company that create the API, and they said the problem was my server. I tried also in local environment, but it's the same problem.

Code:

 $soap = new soapclient( $WS_URL, array('trace' => 1, 'exceptions' => 0));
 $result = $soap->authenticate( $API_KEY );
 $APISession = $result[1];

try {
  echo '<pre>';
    var_dump($soap);
     echo '</pre>';
} catch (Exception $e) {
    echo($soap->__getLastResponse());
    echo PHP_EOL;
    echo( $soap->__getLastRequest());
}

//140 - Document number
//4 - Document Type

 $getdocumentpdflink = $soap->getdocumentpdflink($APISession, 140, 4);

 echo '<pre>';
 print_r($getdocumentpdflink);
 echo '</pre>';

 die;

Reply:

C:\wamp64\www\soap\index.php:13:
object(SoapClient)[1]
  public 'trace' => int 1
  public '_exceptions' => boolean false
  public '_soap_version' => int 1
  public 'sdl' => resource(2, SOAP SDL)
  public '__last_request' => string '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:KI_API3" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:authenticate><apikey xsi:type="xsd:string">464nbbp2189cf9b8de9a39bd6aa9cdc80fd41a7</apikey></ns1:authenticate></SOAP-ENV:Body>'... (length=533)
  public 'httpsocket' => resource(3, stream)
  public '_use_proxy' => int 0
  public 'httpurl' => resource(4, SOAP URL)
  public '__last_request_headers' => string 'POST /API3_ws.php HTTP/1.1
Host: iniciar.netfacturacion.es
Connection: Keep-Alive
User-Agent: PHP-SOAP/7.0.0
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:KI_API3#authenticate"
Content-Length: 533

' (length=215)
  public '__last_response_headers' => string 'HTTP/1.1 200 OK
Date: Fri, 25 Jan 2019 14:41:54 GMT
Content-Type: text/xml; charset=ISO-8859-1
Content-Length: 663
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: Content-Type
Set-Cookie: PHPSESSID=3no7p09ctpm9de911c73p30cs5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Server: NuSOAP Server v0.9.5
X-SOAP-Server: NuS'... (length=531)
  public '_cookies' => 
    array (size=1)
      'PHPSESSID' => 
        array (size=3)
          0 => string '3no7p09ctpm9de911c73p30cs5' (length=26)
          1 => string '/' (length=1)
          2 => string 'iniciar.netfacturacion.es' (length=25)
  public '__last_response' => string '<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:authenticateResponse xmlns:ns1="urn:KI_API3"><return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[2]"><item xsi:type="xsd:string">1</i'... (length=663)
SoapFault Object
(
    [message:protected] => looks like we got no XML document
    [string:Exception:private] => 
    [code:protected] => 0
    [file:protected] => C:\wamp64\www\soap\index.php
    [line:protected] => 22
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [file] => C:\wamp64\www\soap\index.php
                    [line] => 22
                    [function] => __call
                    [class] => SoapClient
                    [type] => ->
                    [args] => Array
                        (
                            [0] => getdocumentpdflink
                            [1] => Array
                                (
                                    [0] => 053017969afdc9f800000464a661e0975230f437
                                    [1] => 140
                                    [2] => 4
                                )

                        )

                )

        )

    [previous:Exception:private] => 
    [faultstring] => looks like we got no XML document
    [faultcode] => Client
    [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
)

Don't understand what may be the problem.

Thank you in advance.

Best regards!

Start by printing out (writing to a file ...) the output which your program actually generates ... which obviously is not valid XML. Remember that XML is much more stringent than, say, HTML.