简体   繁体   中英

Php soapClient array method

Im new to php soapclient. I have been trying to send details and i keep getting an empty response.

I have this soap details

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

kindly help i could not find useful resource online. Thanks. I have made modifications to the highlighted comment. I dont know if i translated the soap correctly into the array i am parsing.

Your code is missing the Whole things it seems like you copied and pasted the source.. So i have just Added the <?php ?> tags to your Code.

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

Now you can try it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM