Skip to content

Commit 01d7df9

Browse files
author
The SoftLayer Developer Network
committed
Merge pull request #4 from SLphil/master
Object masks and default namespace
2 parents 4a331e4 + 3d94002 commit 01d7df9

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

SoftLayer/SoapClient.class.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ class Softlayer_SoapClient extends SoapClient
9696
*/
9797
const API_PRIVATE_ENDPOINT = 'http://api.service.softlayer.com/soap/v3/';
9898

99+
/**
100+
* The namespace to use for calls to the API
101+
*
102+
* $var string
103+
*/
104+
const DEFAULT_NAMESPACE = 'http://api.service.softlayer.com/soap/v3/';
105+
106+
99107
/**
100108
* The API endpoint base URL used by the client.
101109
*
@@ -287,7 +295,7 @@ public static function getClient($serviceName, $id = null, $username = null, $ap
287295
*/
288296
public function addHeader($name, $value)
289297
{
290-
$this->_headers[$name] = new SoapHeader($this->_endpointUrl, $name, $value);
298+
$this->_headers[$name] = new SoapHeader(self::DEFAULT_NAMESPACE, $name, $value);
291299
return $this;
292300
}
293301

@@ -369,26 +377,26 @@ public function setInitParameter($id)
369377
* Set an object mask to a SoftLayer API call
370378
*
371379
* Use an object mask to retrieve data related your API call's result.
372-
* Object masks are skeleton objects that define nested relational
380+
* Object masks are skeleton objects or strings that define nested relational
373381
* properties to retrieve along with an object's local properties.
374382
*
375383
* @see SoftLayer_ObjectMask
376-
* @link http://sldn.softlayer.com/wiki/index.php/Using_Object_Masks_in_the_SoftLayer_API Using object masks in the SoftLayer API
377-
* @link http://sldn.softlayer.com/wiki/index.php/Category:API_methods_that_can_use_object_masks API methods that can use object masks
384+
* @link http://sldn.softlayer.com/article/Using-Object-Masks-SoftLayer-API Using object masks in the SoftLayer API
378385
* @param object $mask The object mask you wish to define
379386
* @return SoftLayer_SoapClient
380387
*/
381388
public function setObjectMask($mask)
382389
{
383390
if (!is_null($mask)) {
384-
if (!($mask instanceof SoftLayer_ObjectMask)) {
385-
throw new Exception('Please provide a SoftLayer_ObjectMask to define an object mask.');
391+
$header = 'SoftLayer_ObjectMask';
392+
393+
if ($mask instanceof SoftLayer_ObjectMask) {
394+
$header = sprintf('%sObjectMask', $this->_serviceName);
386395
}
387396

388397
$objectMask = new stdClass();
389398
$objectMask->mask = $mask;
390-
391-
$this->addHeader($this->_serviceName . 'ObjectMask', $objectMask);
399+
$this->addHeader($header, $objectMask);
392400
}
393401

394402
return $this;

0 commit comments

Comments
 (0)