[英]SOAP API USING CURL
我正在尝试使用Ezidebit的soap API来获取列表中的所有客户。 他们对我的记录非常混乱,似乎缺少了一些东西。 可能是我也没有足够的技能。
该文档位于: https : //www.getpayments.com/docs/#getcustomerlist
我得到的当前响应是:
a:ActionNotSupportedThe message with Action 'run' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
这是我的代码:(我在xml中删除了我的密钥,并替换为000000000000000)
<?php
$soap_request ='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:px="https://px.ezidebit.com.au/">
<soapenv:Header/>
<soapenv:Body>
<px:GetCustomerList>
<px:DigitalKey>000000000000000</px:DigitalKey>
<px:CustomerStatus>ALL</px:CustomerStatus>
<px:OrderBy>EzidebitCustomerID</px:OrderBy>
<px:Order>ASC</px:Order>
<px:PageNumber>1</px:PageNumber>
</px:GetCustomerList>
</soapenv:Body>
</soapenv:Envelope>';
$header = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"run\"",
"Content-length: ".strlen($soap_request),
);
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, "https://api.ezidebit.com.au/v3-5/nonpci" );
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $soap_request);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
$content = curl_exec($soap_do);
if(curl_exec($soap_do) === false) {
$err = 'Curl error: ' . curl_error($soap_do);
curl_close($soap_do);
print $err;
} else {
curl_close($soap_do);
print_r($content);
}
?>
我可以看到错误指的是:“ SOAPAction:\\“ run \\”“的标题,但是我不确定我要替换的位置。
希望有人可以帮助我。
如果您不知道如何使用本机PHP SoapClient类(这是在PHP中使用SOAP的最佳方法),请使用WSDL到php生成器,它将所有内容包装在结构化类中,因此您不会怀疑您是否在任何地方做错了。 如果有错误,您将准确地识别它。 除了PackageGenerator项目,我别无其他建议
尝试将SOAPAction标头更改为
“ SOAPAction:\\” https://px.ezidebit.com.au/INonPCIService/GetCustomerList \\“”
在此服务的WSDL中,您可以找到
<wsdl:operation name="GetCustomerList"><wsdl:input wsaw:Action="https://px.ezidebit.com.au/INonPCIService/GetCustomerList"
现在的代码:
$soap_request ='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:px="https://px.ezidebit.com.au/">
<soapenv:Header/>
<soapenv:Body>
<px:GetCustomerList>
<px:DigitalKey>000000000000000</px:DigitalKey>
<px:CustomerStatus>ALL</px:CustomerStatus>
<px:OrderBy>EzidebitCustomerID</px:OrderBy>
<px:Order>ASC</px:Order>
<px:PageNumber>1</px:PageNumber>
</px:GetCustomerList>
</soapenv:Body>
</soapenv:Envelope>';
$header = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"https://px.ezidebit.com.au/INonPCIService/GetCustomerList\"",
"Content-length: ".strlen($soap_request),
);
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, "https://api.ezidebit.com.au/v3-5/nonpci" );
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $soap_request);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
$content = curl_exec($soap_do);
if(curl_exec($soap_do) === false) {
$err = 'Curl error: ' . curl_error($soap_do);
curl_close($soap_do);
print $err;
} else {
curl_close($soap_do);
print_r($content);
}
给出一个错误
无效的数字密钥。
与SoapClient相同:
$wsdl = 'https://api.demo.ezidebit.com.au/v3-5/nonpci?wsdl';
$client = new SoapClient($wsdl, array('soap_version' => SOAP_1_1, 'trace' => 1, "exceptions" => 0));
$params = [
'DigitalKey' => '8591BFD4-E7C8-4284-84F7-E6C419114FA8',
'CustomerStatus' => 'ALL',
'OrderBy' => 'EzidebitCustomerID',
'Order' => 'ASC',
'PageNumber' => 1
];
$result = $client->__soapCall('GetCustomerList', [$params]);
print_r($client->__getLastRequest());
echo PHP_EOL;
print_r($result);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.