Php soapClient数组方法

时间:2017-09-14 13:19:25

标签: php soap wsdl soap-client

我是php soapclient的新手。我一直试图发送详细信息而且我一直在回复。

我有这个肥皂细节

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <UploadFileNew_XML xmlns="http://tempuri.org/GAPS_Uploader/FileUploader">
      <xmlRequest>
    <transdetails>
      <transactions>
        <transaction>
          <amount>25000</amount>
          <paymentdate>2017/09/07</paymentdate>
          <reference>777777</reference>
          <remarks>Name</remarks>
          <vendorcode>vendor details</vendorcode>
          <vendorname>Vendor name</vendorname>
          <vendoracctnumber>0212893398</vendoracctnumber>
          <vendorbankcode>058152052</vendorbankcode>
        </transaction>
      </transactions>>
    </transdetails>
    <customerid>481472280</customerid>
    <username>username</username>
    <password>password</password>
    <hash>'.hash(sha512,'hasdetails','other details').'</hash>
      </xmlRequest>
    </UploadFileNew_XML>
  </soap:Body>
</soap:Envelope>
<?php
try{
    define ('WSDL_URL_BAL','http://gtweb.gtbank.com/gaps_fileuploader/fileuploader.asmx?WSDL');
 $stringsample = [];
$stringsample['transdetails']['transactions']['transaction']['amount'] = 2500;
$stringsample['transdetails']['transactions']['transaction']['paymentdate'] = '2017/09/07';
$stringsample['transdetails']['transactions']['transaction']['reference'] = 'aaaaaa';
$stringsample['transdetails']['transactions']['transaction']['remarks'] = 'bbbbbbb';
$stringsample['transdetails']['transactions']['transaction']['vendorcode'] = 'cccccccc';
$stringsample['transdetails']['transactions']['transaction']['vendorname'] = 'ddddddd';
$stringsample['transdetails']['transactions']['transaction']['vendoracctnumber'] = '0212893398';
$stringsample['transdetails']['transactions']['transaction']['vendorbankcode'] = '058152052';
$stringsample['customerid'] = '12345';
$stringsample['customerid'] = 'abcdefrggg';
$stringsample['customerid'] = '445566555';
$stringsample['hash'] = 'hash';
$endpoint = WSDL_URL_BAL;
$client = new SoapClient( $endpoint );
$params = array('xmlrequest'=>$stringsample);
$result = $client->UploadFileNew_XML($params);
$data = $result->UploadFileNew_XMLResult;
echo $data.'<br /><br /><br />';
print_r($data); echo '<br /><br /><br />';
}  catch (Exception $e) {
    $message = 'Error: '. $e->getMessage();
}
echo $message;
?>

请帮助我在网上找不到有用的资源。谢谢。 我对突出显示的评论进行了修改。 我不知道我是否正确地将肥皂翻译成我正在解析的数组。

1 个答案:

答案 0 :(得分:0)

您的代码缺少您复制并粘贴源代码的全部内容..所以我刚刚将<?php ?>代码添加到您的代码中。

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <UploadFileNew_XML xmlns="http://tempuri.org/GAPS_Uploader/FileUploader">
      <xmlRequest>
    <transdetails>
      <transactions>
        <transaction>
          <amount>25000</amount>
          <paymentdate>2017/09/07</paymentdate>
          <reference>777777</reference>
          <remarks>Name</remarks>
          <vendorcode>vendor details</vendorcode>
          <vendorname>Vendor name</vendorname>
          <vendoracctnumber>0212893398</vendoracctnumber>
          <vendorbankcode>058152052</vendorbankcode>
        </transaction>
      </transactions>>
    </transdetails>
    <customerid>481472280</customerid>
    <username>username</username>
    <password>password</password>
    <hash>'.hash(sha512,'hasdetails','other details').'</hash>
      </xmlRequest>
    </UploadFileNew_XML>
  </soap:Body>
</soap:Envelope>
<?php
try{
define ('WSDL_URL_BAL','http://gtweb.gtbank.com/gaps_fileuploader/fileuploader.asmx?WSDL');
$client = new SoapClient( $endpoint );
$params = array('xmlrequest'=>$stringsample);
$result = $client->UploadFileNew_XML($params);
$data = $result->UploadFileNew_XMLResult;
echo $data.'<br /><br /><br />';
print_r($data); echo '<br /><br /><br />';
}  catch (Exception $e) {
    $message = 'Error: '. $e->getMessage();
}
echo $message;
?>

现在你可以尝试一下。