你能帮我吗?当我在PHP中运行SOAP请求时,我得到了成功的结果,但结果中没有项目。就像下面这个。。。
<?php
$wsdl='https://api.n11.com/ws/SapCommissionEInvoiceDetailService.wsdl';
$soap = new SoapClient($wsdl);
$searchData = array(
"auth" => array(
"appKey" => '***********',
"appSecret" => '*******'),
"date" => '2020-06');
$result = $soap->GetSapCommissionEInvoiceDetail($searchData);
// Echo the result
echo "<pre>".print_r($result, true)."</pre>";
?>
当我通过SOAPUI运行请求时,我得到了所有期望的项目。就像下面这个。。。
SOAPUI请求和响应
你能告诉我我怎么了吗?
当我在这个api中调用其他方法时,我可以毫无问题地获得所有项目。但在这种方法(GetSapCommissionEInvoiceDetail(中,我遇到了一个大问题。请帮忙——我花了七天时间寻找解决方案。
更新
回波的输出(结果(为:
stdClass对象([result]=>stdClass对象([status]=>成功)
[commissionInvoiceDetail] => stdClass Object
(
[commissionInvoiceDetailDataList] => stdClass Object
(
)
)
)
UPDATE_2:我添加了2行来捕捉错误。
echo "REQUEST:n" . htmlentities($soap->__getLastRequest()) . "n";
echo "Response:n" . htmlentities($soap->__getLastResponse()) . "n";
__getLastReques的结果是:
REQUEST: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.n11.com/ws/schemas"><SOAP-ENV:Body><ns1:GetSapCommissionEInvoiceDetailRequest><auth><appKey>*************</appKey><appSecret>**************</appSecret></auth><date>2020-06</date></ns1:GetSapCommissionEInvoiceDetailRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
getLastResponse的结果是:
Response: <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><ns3:GetSapCommissionEInvoiceDetailResponse xmlns="" xmlns:ns3="http://www.n11.com/ws/schemas"><result><status>success</status></result><commissionInvoiceDetail><commissionInvoiceDetailDataList><commissionInvoiceItemDetailData><addOrder>0,00</addOrder><belnr>0400201769</belnr><malzemeKodu></malzemeKodu><miktar>1</miktar><orderItemId>208851060</orderItemId><orderNumber>205978544774</orderNumber><pazarlamaGeliri>0,00</pazarlamaGeliri><saticiId></saticiId><tamamlanmaTarihi>08.06.2020</tamamlanmaTarihi><transactionDDText>Satış Kargo (SPP)</transactionDDText><transactionType>SKS</transactionType><tutar>8,34</tutar><vadeFarki>0,00</vadeFarki></commissionInvoiceItemDetailData><commissionInvoiceItemDetailData><addOrder>0,00</addOrder><belnr>0400201769</belnr><malzemeKodu></malzemeKodu><miktar>1</miktar><orderItemId>208785323</orderItemId><orderNumber>205387444774</orderNumber>
因此XML的结果不是NULL。它是完美的。但回声的结果是:
stdClass Object
([result]=>stdClass对象([status]=>成功)
[commissionInvoiceDetail] => stdClass Object
(
[commissionInvoiceDetailDataList] => stdClass Object
(
)
)
)
echo的结果为NULL。所以我在打印结果时犯了一些错误。帮助PLSSSSSS(((
我没有任何方法用您尝试使用的API来测试这一点,但请尝试:
$soap = new SoapClient($wsdl, [
'features' => SOAP_USE_XSI_ARRAY_TYPE,
'exceptions' => true
]);
$soap->__setSoapHeaders([]);
PHP soap客户端可能很难解释从API返回的XML数组的类型。如果没有其他情况,exceptions
键为true可能会提醒您注意其他问题。