我正在我的一个客户wordpress网站上使用PHP与Kashflow集成,并且在PHP5.6之前运行良好,但是当我将网站升级到PHP7.1时问题就到了,所以下面是我得到的错误, 致命错误 :未捕获的SoapFault异常:[客户端] SOAP错误:编码:SoapVar没有'enc_type'属性
下面是我的Kashflow类代码:
public function insertInvoice(KashflowInvoice $invoice)
{
$lines = $this->prepareInvoiceLines($invoice->getLines());
$parameters['Inv'] = array
(
"InvoiceDBID" => 0,
"InvoiceNumber" => $invoice->getInvoiceNumber(),
"InvoiceDate" => $invoice->getInvoiceDate(),
"DueDate" => $invoice->getDueDate(),
"Customer" => "",
"CustomerID" => $invoice->getKashflowCustomerId(),
"Paid" => 1,
"CustomerReference" => "",
"EstimateCategory" => "",
"SuppressTotal" => 1,
"ProjectID" => 0,
"CurrencyCode" => "GBP",
"ExchangeRate" => 1,
"ReadableString" => "",
"Lines" => $lines,
"NetAmount" => $invoice->getNet(),
"VATAmount" => $invoice->getTax(),
"AmountPaid" => 0,
"CustomerName" => "",
"UseCustomDeliveryAddress" => 0
);
print_r($parameters);
return $this->makeRequest("InsertInvoice",$parameters);
}
private function prepareInvoiceLines($invoice_lines)
{
if(NULL == $invoice_lines)
return array();
$lines = NULL;
foreach($invoice_lines as $invoice_line)
{
$line = array(
"LineID" => 0,
"Quantity" => $invoice_line['qty'],
"Description" => $invoice_line['description'],
"Rate" => $invoice_line['unit_net'],
"ChargeType" => $invoice_line['nominal_id'],
"VatAmount" => $invoice_line['qty'] * $invoice_line['unit_tax'],
"VatRate" => $invoice_line['tax_rate'],
"Sort" => 1,
"ProductID" => 0,
"ProjID" => $invoice_line['project_id']
);
// Lines is an array of InvoiceLine as anyType.
$lines[] = new SoapVar($line,0,"InvoiceLine","KashFlow");
}
return $lines;
}
我调试了这段代码,如果我注释“ $ lines [] = new SoapVar($ line,0,“ InvoiceLine”,“ KashFlow”);”,它就是创意发票。所以我不确定在这行上要更改什么。
您的帮助将不胜感激。
谢谢。
答案 0 :(得分:1)
而不是用def plots(ims, figsize=(12,6), rows=3, interp=False, titles=None):
if type(ims[0]) is np.ndarray:
ims = np.array(ims).astype(np.uint8)
if (ims.shape[-1] != 3):
ims = ims.transpose((0,2,3,1))
f = plt.figure(figsize=figsize)
cols = len(ims)//rows if len(ims) % 2 == 0 else len(ims)//rows + 1
for i in range(len(ims)):
sp = f.add_subplot(rows, cols, i+1)
sp.axis('Off')
if titles is not None:
sp.set_title(titles[i], fontsize=16)
plt.imshow(ims[i], interpolation=None if interp else 'none')
imgs, labels = next(train_batches)
plots(imgs, titles=labels)
替换0,它对我来说是php 7.0版
SOAP_ENC_OBJECT
答案 1 :(得分:0)
$ lines [] = new SoapVar($ line,0,“ InvoiceLine”,“ KashFlow”);
第二个参数应为常量。例如,尝试使用SOAP_ENC_OBJECT。可以在php文档中找到更多信息:http://php.net/manual/en/soapvar.soapvar.php参见示例#1。您可以尝试使用的常量列表在这里:http://php.net/manual/en/soap.constants.php。对于基本类型和SOAP_ENC_ *,有效的方法会盯住XSD_。 如果失败,请发布wsdl文件。