SoftLayer provides an XML-RPC interface in addition to SOAP and REST. The XML-RPC API is built to mimic the SOAP interface. We recommend using the XML-RPC API when your chosen language doesn’t have proper SOAP support.
The SoftLayer XML-RPC API has one endpoint per available API service. Each endpoint has a unique URL containing the service name of the API services that it calls. For example:
https://api.softlayer.com/xmlrpc/v3/<serviceName>
or
http://api.service.softlayer.com/xmlrpc/v3/<serviceName>
In these examples, "<serviceName>"
would be replaced with the name of the API service you wish to call. Use the second URL to access the XML-RPC API over SoftLayer’s private network. It’s a faster, more secure way to communicate with SoftLayer, but the system making API calls must be on SoftLayer’s private network. All SoftLayer servers come with access to our private network, including CCIs. Additional private IP addresses are available for purchase should they be needed.
The SoftLayer_Account/getObject|getObject() method in the SoftLayer_Account service is a simple call that only requires an authentication header. It returns basic, top-level information about your SoftLayer account and is a great way to test your first API call. Here are a few ways to get it going:
<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>getObject</methodName>
<params>
<param>
<value>
<struct>
<member>
<name>headers</name>
<value>
<struct>
<member>
<name>authenticate</name>
<value>
<struct>
<member>
<name>username</name>
<value>
<string>set me</string>
</value>
</member>
<member>
<name>apiKey</name>
<value>
<string>set me too</string>
</value>
</member>
</struct>
</value>
</member>
</struct>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>
The XML-RPC API’s data types mimic the same data types found in the SOAP API. Complex types are modeled as XML-RPC struct
s. Declare and receive these struct
s when working with method parameters and return types. A SoftLayer_Hardware_Server is rendered as a collection of simple types:
<xml>
<struct>
<member>
<name>id</name>
<value>
<int>1234</int>
</value>
</member>
<member>
<name>hostname</name>
<value>
<string>test</string>
</value>
</member>
<member>
<name>domain</name>
<value>
<string>example.org</string>
</value>
</member>
<member>
<name>fullyQualifiedDomainName</name>
<value>
<string>test.example.org</string>
</value>
</member>
<member>
<name>hardwareStatusid</name>
<value>
<int>2</int>
</value>
</member>
<member>
<name>accountId</name>
<value>
<int>12345</int>
</value>
</member>
<member>
<name>bareMetalInstanceFlag</name>
<value>
<boolean>0</boolean>
</value>
</member>
</struct>
</xml>
The first parameter in every XML-RPC call is a
named “headers”. Your headers parameter contains the headers required for your API call to work, such as authentication and initialization parameters. Like their SOAP complex type equivalent, these headers are modeled as
objects in your call’s XML. This sample header parameter contains authentication information and an initialization parameter for the [[SoftLayer_Hardware_Server]] API service:
<xml>
<struct>
<member>
<name>headers</name>
<value>
<struct>
<member>
<name>authenticate</name>
<value>
<struct>
<member>
<name>username</name>
<value>
<string>set me</string>
</value>
</member>
<member>
<name>apiKey</name>
<value>
<string>set me!</string>
</value>
</member>
</struct>
</value>
</member>
<member>
<name>SoftLayer_Hardware_ServerInitParameters</name>
<value>
<struct>
<member>
<name>id</name>
<value>
<string>1234</string>
</value>
</member>
</struct>
</value>
</member>
</struct>
</value>
</member>
</struct>
</xml>
Add an object mask to your API call by adding a
to your headers parameter with the name “
corresponds to the name of the API service you are calling. For instance, an object mask for the SoftLayer_Account API service has the name SoftLayer_AccountObjectMask
and the SoftLayer_Hardware_Server service’s corresponding object mask class name is SoftLayer_Hardware_ServerObjectMask
.
Declare a
inside your object with the name “mask” containing the relational and count properties you wish to retrieve along with your API call result. Each item in your object mask is a
with the name of the property you wish to retrieve and an empty array value.
This example retrieves the following information:
<xml>
<struct>
<member>
<name>SoftLayer_Hardware_ServerObjectMask</name>
<value>
<struct>
<member>
<name>mask</name>
<value>
<struct>
<member>
<name>operatingSystem</name>
<value>
<struct>
<member>
<name>passwords</name>
<value>
<array>
<data/>
</array>
</value>
</member>
</struct>
</value>
</member>
<member>
<name>networkComponents</name>
<value>
<array>
<data/>
</array>
</value>
</member>
<member>
<name>datacenter</name>
<value>
<array>
<data/>
</array>
</value>
</member>
<member>
<name>processorCount</name>
<value>
<array>
<data/>
</array>
</value>
</member>
</struct>
</value>
</member>
</struct>
</value>
</member>
</struct>
</xml>
Place a result limit in your API call by adding a
to your headers parameter with the name “resultLimit” containing two members:
<xml>
<struct>
<member>
<name>resultLimit</name>
<value>
<struct>
<member>
<name>limit</name>
<value>
<int>2</int>
</value>
</member>
<member>
<name>offset</name>
<value>
<int>0</int>
</value>
</member>
</struct>
</value>
</member>
</struct>
</xml>
The XML-RPC API returns XML-RPC faults if your call encounters an error. You may receive different faultCodes
and faultStrings
depending on your error. The table below lists the most common faultCode and faultString returns you may receive.
faultCode faultString Reason
-32601 “server error. requested method not found” The API service youare querying doesn’t contain the method youare calling or your call is missing a
As with REST, the XML-RPC API cannot determine extended complex types in certain parameters. In these cases you should define a complexType
property in your complex parameters set to the type of object you’re sending to your method.