使用CURL的SOAP API

参孙史密斯

我正在尝试使用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 \”“的标题,但是我不确定我要替换的位置。

希望有人可以帮助我。

瓦迪姆·科金(Vadim Kokin)

尝试将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);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章