dq23171 2014-09-24 07:49
浏览 63

PHP SoapClient缺少数据

I'm using a SoapClient (zend2), but for some reasons, can't get complete data answer

$client = new \SoapClient($host);
$result = $client->getInvoice();

$result var_dump:

["ListInvoiceResult"] => object(stdClass)#282 (4) {
["Status"] => int(1)
["ErrorCode"] => NULL
["ErrorMessage"] => string(0) ""
["Invoice"] => array(1436) {
[0] => object(stdClass)#283 (3) {
["ID"] => int(12741)
["Date"] => string(10) "2011.01.31"
["DateSales"] => string(10) "2011.01.31"
}

Above object missing a variable InvoiceNumber

But when I call __getLastResponse method , I've recieved complete data with InvoiceNumber

 <p1:Invoice>
<p1:ID>12741</p1:ID>
<p1:InvoiceNumber>1|FA|2011|00633</p1:InvoiceNumber>
<p1:Date>2011.01.31</p1:Date>
<p1:DateSales>2011.01.31</p1:DateSales>
</p1:Invoice>

Hmmm. Looks strange. But all other methods returns complete data, even variable Invoice Number..

  • 写回答

1条回答 默认 最新

  • dongsi1954 2014-09-24 07:59
    关注

    I think you should try using the classmap option in SoapClient or check you mapped classes, for instance:

    class MyBook {
    public $title;
    public $author;
    }
    
    $server = new SoapClient("books.wsdl", array('classmap' => array('book' => "MyBook")));
    

    In your case you should model ListInvoiceResult and Invoice class for instance:

    class WS_ListInvoiceResult {
    public $Status;
    public $ErrorCode;
    public $ErrorMessage;
    public $Invoice;
    }
    
    class WS_Invoice {
    public $ID;
    public $Date;
    public $DateSales;
    public $InvoiceNumber;
    }
    

    And connect to soap api as such:

    $server = new SoapClient("wsdl path", array('classmap' => array("ListInvoiceResult" => "WS_ListInvoiceResult", "Invoice" => "WS_Invoice")));
    

    If this doesn't help try checking your WSDL, though based on the response it appears to be OK.

    评论

报告相同问题?

悬赏问题

  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败