我正在使用SoapClient(zend2),但由于某些原因,无法获得完整的数据答案
$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"
}
上方对象缺少变量 InvoiceNumber
但是当我调用__getLastResponse方法时,我收到了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>
嗯。看起来很奇怪但是所有其他方法都返回完整的数据,甚至是变量Invoice Number ..
答案 0 :(得分:0)
我认为您应该尝试使用SoapClient中的 classmap 选项或检查映射的类,例如:
class MyBook {
public $title;
public $author;
}
$server = new SoapClient("books.wsdl", array('classmap' => array('book' => "MyBook")));
在您的情况下,您应该建模ListInvoiceResult和Invoice类,例如:
class WS_ListInvoiceResult {
public $Status;
public $ErrorCode;
public $ErrorMessage;
public $Invoice;
}
class WS_Invoice {
public $ID;
public $Date;
public $DateSales;
public $InvoiceNumber;
}
并连接到soap api:
$server = new SoapClient("wsdl path", array('classmap' => array("ListInvoiceResult" => "WS_ListInvoiceResult", "Invoice" => "WS_Invoice")));
如果这对尝试检查您的WSDL没有帮助,虽然根据响应它似乎没问题。