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.

    评论

报告相同问题?

悬赏问题

  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统