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

时间:2019-01-25 14:46:48

标签: php xml api soap

我已经到处搜索,但是找不到解决我问题的方法。

我正在尝试连接到API,但出现此错误“看起来我们没有XML文档”。

我向创建API的公司发送了一封电子邮件,他们说问题出在我的服务器上。我也在本地环境中尝试过,但这是同样的问题。

代码:

 $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;

回复:

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/
)

不知道可能是什么问题。

先谢谢您。

最诚挚的问候!

1 个答案:

答案 0 :(得分:0)

打印(写入文件...)开始,您的程序实际生成的输出...显然是无效的XML。请记住,XML比HTML严格得多。