Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4 from SLphil/master

Object masks and default namespace
  • Loading branch information...
commit 01d7df956731b8e8864b1185748afdf33f9f664f 2 parents 4a331e4 + 3d94002
The SoftLayer Developer Network authored
Showing with 16 additions and 8 deletions.
  1. +16 −8 SoftLayer/SoapClient.class.php
View
24 SoftLayer/SoapClient.class.php
@@ -97,6 +97,14 @@ class Softlayer_SoapClient extends SoapClient
const API_PRIVATE_ENDPOINT = 'http://api.service.softlayer.com/soap/v3/';
/**
+ * The namespace to use for calls to the API
+ *
+ * $var string
+ */
+ const DEFAULT_NAMESPACE = 'http://api.service.softlayer.com/soap/v3/';
+
+
+ /**
* The API endpoint base URL used by the client.
*
* @var string
@@ -287,7 +295,7 @@ public static function getClient($serviceName, $id = null, $username = null, $ap
*/
public function addHeader($name, $value)
{
- $this->_headers[$name] = new SoapHeader($this->_endpointUrl, $name, $value);
+ $this->_headers[$name] = new SoapHeader(self::DEFAULT_NAMESPACE, $name, $value);
return $this;
}
@@ -369,26 +377,26 @@ public function setInitParameter($id)
* Set an object mask to a SoftLayer API call
*
* Use an object mask to retrieve data related your API call's result.
- * Object masks are skeleton objects that define nested relational
+ * Object masks are skeleton objects or strings that define nested relational
* properties to retrieve along with an object's local properties.
*
* @see SoftLayer_ObjectMask
- * @link http://sldn.softlayer.com/wiki/index.php/Using_Object_Masks_in_the_SoftLayer_API Using object masks in the SoftLayer API
- * @link http://sldn.softlayer.com/wiki/index.php/Category:API_methods_that_can_use_object_masks API methods that can use object masks
+ * @link http://sldn.softlayer.com/article/Using-Object-Masks-SoftLayer-API Using object masks in the SoftLayer API
* @param object $mask The object mask you wish to define
* @return SoftLayer_SoapClient
*/
public function setObjectMask($mask)
{
if (!is_null($mask)) {
- if (!($mask instanceof SoftLayer_ObjectMask)) {
- throw new Exception('Please provide a SoftLayer_ObjectMask to define an object mask.');
+ $header = 'SoftLayer_ObjectMask';
+
+ if ($mask instanceof SoftLayer_ObjectMask) {
+ $header = sprintf('%sObjectMask', $this->_serviceName);
}
$objectMask = new stdClass();
$objectMask->mask = $mask;
-
- $this->addHeader($this->_serviceName . 'ObjectMask', $objectMask);
+ $this->addHeader($header, $objectMask);
}
return $this;

0 comments on commit 01d7df9

Please sign in to comment.
Something went wrong with that request. Please try again.