0
votes

I am trying to pull the user information from a billing item using PHP - just like in this example: https://knowledgelayer.softlayer.com/procedure/how-extract-user-billing-information-using-softlayers-api.

My code:

?php
require_once __DIR__.'/vendor/autoload.php';
.
.
.
$client = \SoftLayer\SoapClient::getClient('SoftLayer_Account', null, $apiUsername, $apiKey);

$mask = "mask[id,orderItem[id,order[userRecordId,userRecord[username]]],invoiceItem[id,totalRecurringAmount]]";
$client->setObjectMask($mask);
$userBill = $client->getNextInvoiceTopLevelBillingItems();
?>

However, I get this error if invoiceItem included in the mask.

PHP Fatal error:  Uncaught SoapFault exception: [SOAP-ENV:Server] Internal Error in /opt/devices/vendor/softlayer/softlayer-api-php-client/src/SoapClient.php:200
Stack trace:
#0 /opt/devices/vendor/softlayer/softlayer-api-php-client/src/SoapClient.php(200): SoapClient->__call('getNextInvoiceT...', Array, NULL, Array, Array)
#1 /opt/devices/invoiceProd3.php(17): SoftLayer\SoapClient->__call('getNextInvoiceT...', Array)
#2 /opt/devices/invoiceProd3.php(17): SoftLayer\SoapClient->getNextInvoiceTopLevelBillingItems()
#3 {main}
   thrown in /opt/devices/vendor/softlayer/softlayer-api-php-client/src/SoapClient.php on line 200

When the mask is limited to orderItem, all is good. That is, this mask works just fine.

$mask = "mask[id,orderItem[id,order[userRecordId,userRecord[username]]]];

However, no luck with invoiceItem.

   "mask[id,invoiceItem[id,totalRecurringAmount]]";

I'm using the 9/25/2015 soap client.

1

1 Answers

0
votes

for me your request is working fine using PHP, so the issue is likely that your request is returning a big amount of data, when you are using the API and the request is fetching a lot of data you may get internal errors like the one that you got. In order to solve that issue you have the followings options:

1.- Reduce the amount of data, like you did reducing the objectMask or using objectFilters 2.- Increase the timeout of the request, you can do this at moment to create the client e.g.:

 $client = \SoftLayer\SoapClient::getClient($serviceName, null, $empUsername, $empPassword, $endPoint, array(
'trace' =>true,
'connection_timeout' => 500000000,
'keep_alive' => false,
));

3.- Use pagination (result limits) in order to fetch less data in the request, you can see how to do that here: https://sldn.softlayer.com/article/PHP