2017-09-14 66 views
0

Im新的php soapclient。我一直在嘗試發送詳細信息,並一直得到空的答覆。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; 
?> 

好心幫我不能在網上找到有用的資源。謝謝。 我對突出顯示的評論進行了修改。 我不知道如果我正確地將肥皂翻譯成我解析的數組。

回答

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; 
?> 

現在你可以試試它。

+0

是的,我錯過了PHP標記,它仍然不工作 – user297056

+0

但它不會工作!因爲try()catch(Exception $ e){}'方法用於sql查詢。在你的define()中,它的工作原理是什麼?和變量$端點,$ stringsample,$ params從哪裏得到?上面沒有任何聲明。 –

+0

已作出修改。謝謝 – user297056