【问题标题】:SOAP CLIENTE | "looks like we got no XML document" | PHP 7肥皂客户端 | “看起来我们没有 XML 文档” | PHP 7
【发布时间】:2019-01-25 14:46:48
【问题描述】:

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

我正在尝试连接到 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/
)

不明白可能是什么问题。

提前谢谢你。

最好的问候!

【问题讨论】:

  • 如果直接访问 wsdl url 会发生什么?你得到 XML 并且它有效吗?
  • API 中的其他方法工作正常,只有这个方法会出现此错误。

标签: php xml api soap


【解决方案1】:

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

【讨论】:

  • 我会认为这更像是一个评论而不是一个答案。
猜你喜欢
  • 1970-01-01
  • 2017-01-29
  • 2013-12-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-27
  • 1970-01-01
  • 2014-02-11
相关资源
最近更新 更多