<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SoftLayer Blog &#187; Kevin Trachier</title>
	<atom:link href="http://blog.softlayer.com/author/ktrachier/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.softlayer.com</link>
	<description>A Behind the Scenes Look at the Best Hosting Provider in the World</description>
	<lastBuildDate>Wed, 15 May 2013 15:33:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>SOAP API Application Development 101</title>
		<link>http://blog.softlayer.com/2011/softlayer-soap-api-application-development-101/</link>
		<comments>http://blog.softlayer.com/2011/softlayer-soap-api-application-development-101/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 13:30:47 +0000</pubDate>
		<dc:creator>Kevin Trachier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[coder]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[SLDN]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[walkthrough]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/2011/</guid>
		<description><![CDATA[Simple Object Access Protocol (SOAP) is built on server-to-server remote procedure calls over HTTP. The data is formatted as XML; this means secure, well formatted data will be sent and received from SoftLayer&#8217;s API. This may take a little more time to set up than the REST API but it can be more scalable as [...]]]></description>
			<content:encoded><![CDATA[<p>Simple Object Access Protocol (SOAP) is built on server-to-server remote procedure calls over HTTP. The data is formatted as XML; this means secure, well formatted data will be sent and received from SoftLayer&#8217;s API. This may take a little more time to set up than the REST API but it can be more scalable as you programmatically interface with it. SOAP&#8217;s ability to tunnel through existing protocols such as HTTP and innate ability to work in an object-oriented structure make it an excellent choice for interaction with the SoftLayer API.</p>
<p>This post gets pretty technical and detailed, so it might not appeal to our entire audience. If you&#8217;ve always wondered how to get started with SOAP API development, this post might be a good jumping-off point.</p>
<p><span id="more-3919"></span></p>
<p><strong>Authentication</strong><br />
Before you start playing with the SoftLayer SOAP API, you will need to find your API authentication token. Go into your portal account, and click the &#8220;Manage API Access&#8221; link from the API page under the Support tab. At the bottom of the page you&#8217;ll see a drop down menu for you to &#8220;Generate a new API access key&#8221; for a user. After you select a user and click the &#8220;Generate API Key&#8221; button, you will see your username and your API key. Copy this API key, as you&#8217;ll need it to send commands to SoftLayer&#8217;s API.</p>
<p><strong>PHP</strong><br />
In PHP 5.0+ there are built in classes to deal with SOAP calls. This allows us to quickly create an object oriented, server side application for handling SOAP requests to SoftLayer&#8217;s API. This tutorial is going to focus on PHP 5.1+ as the server side language for making SOAP function calls. If you haven’t already, you will need to install the soap client for php, <a href="http://www.php.net/manual/en/soap.installation.php">here</a> is a link with directions.</p>
<h3>Model View Controller </h3>
<p>Model-View-Controller or MVC is a software architecture commonly used in web development. This architecture simply provides separation between a data abstraction layer (model), the business logic (controller), and the resulting output and user interface (view). Below, I will describe each part of our MVC &#8220;hello world&#8221; web application and dissect the code so that you can understand each line.</p>
<p>To keep this entry a little smaller, the code snippits I reference will be posted on their own page: <a href="http://blog.softlayer.com/soap-api-code-examples/">SOAP API Code Examples</a>. Protip: Open the code snippit page in another window so you can seamlessly jump between this page and the code it&#8217;s referencing.</p>
<p><strong>Model</strong><br />
The first entry on the API Code Examples page is &#8220;The Call Class,&#8221; a custom class for making basic SOAP calls to SoftLayer&#8217;s API. This class represents our model: The SOAP API Call. When building a model, you need to think about what properties that model has, for instance, a model of a person might have the properties: first name, height, weight, etc. Once you have properties, you need to create methods that use those properties. </p>
<p>Methods are verbs; they describe what a model can do. Our &#8220;person&#8221; model might have the methods: run, walk, stand, etc. Models need to be self-sustaining, that means we need to be able to set and get a property from multiple places without them getting jumbled up, so each model will have a &#8220;set&#8221; and &#8220;get&#8221; method for each of its properties. A model is a template for an object, and when you store a model in a variable you are instantiating an instance of that model, and the variable is the instantiated object. </p>
<ul>
<li><strong>Properties and Permissions</strong><br />
Our model has these properties: username, password (apiKey), service, method, initialization parameters, the service&#8217;s WSDL, SoftLayer&#8217;s type namespace, the SOAP API client object, options for instantiating that client, and a response value. The SOAP API client object is built into php 5.1+ (take a look at the “PHP” section above), as such, our model will instantiate a SOAP API object and use it to communicate to SoftLayer&#8217;s SOAP API. </p>
<p>Each of our methods and properties are declared with certain permissions (protected, private, or public), these set whether or not outside functions or extended classes can have access to these properties or methods. I &#8220;set&#8221; things using the &#8220;<code>$this</code>&#8221; variable, <code>$this</code> represents the immediate class that the method belongs to.  I also use the arrow operator (<code>-></code>), which accesses a property or method (to the right of the arrow) that belongs to <code>$this</code> (or anything to the left of the arrow). I gave as many of the properties default values as I could, this way when we instantiate our model we have a fully fleshed out object without much work, this comes in handy if you are instantiating many different objects at once.</li>
<li><strong>Methods</strong><br />
I like to separate my methods into 4 different groups: Constructors, Actions, Sets, and Gets:</p>
<ul>
<li><strong>Sets and Gets</strong><br />
Sets and Gets simply provide a place within the model to set and get properties of that model. This is a standard of object oriented programing and provides the model with a good bit of scalability. Rather than accessing the property itself, always refer to the function that gets or sets the property. This can prevent you from accidentally changing value of the property when you are trying to access it. Lines 99 to the end of our call are where the sets and gets are located.<br/><br/></li>
<li><strong>Constructors</strong><br />
Constructors are methods dedicated to setting options in the model, lines 23-62 of the call model are our constructors. The beauty of these three functions is that they can be copied into any model to perform the same function, just make sure you keep to the <a href="http://framework.zend.com/manual/en/coding-standard.overview.html">Zend coding standards</a>.</p>
<p>First, let’s take a look at the <code>__construct</code> method on line 24. This is a special <a href="http://php.net/manual/en/language.oop5.magic.php">magic php method</a> that always runs immediately when the model is instantiated. We don’t want to actually process anything in this method because if we want to use the default object we will not be passing any options to it, and unnecessary processing will slow response times. We pass the options in an array called <code>Setup</code>, notice that I am using <a href="http://www.php.net/manual/en/language.oop5.typehinting.php">type hinting</a> and <a href="http://php.net/manual/en/functions.arguments.php">default parameters</a> when declaring the function, this way I don’t have to pass anything to model when instantiating. If values were passed in the <code>$Setup</code> variable (which must be an array), then we will run the “<code>setOptions”</code> method.</p>
<p>Now take a look at the <code>setOptions</code> method on line 31. This method will search the model for a set method which matches the option passed in the <code>$setup</code> variable using the built in <code>get_class_methods</code> <a href="http://us.php.net/manual/en/function.get-class-methods.php">function</a>. It then passes the value and name of that option to another magic method, the <code>__set</code> method.</p>
<p>Finally, let’s take a look at the <code>__set</code> and <code>__get</code> methods on lines 45 and 54. These methods are used to create a kind of shorthand access to properties within the model, this is called overloading. Overloading allows the controller to access properties quicker and more efficiently.<br/></li>
<li><strong>Actions</strong><br />
Actions are the traditional verbs that I mentioned earlier; they are the “run”, “walk”, “jump”, and “climb” of our person model. We have 2 actions in our model, the response action and the createHeaders action.</p>
<p><strong>The createHeaders action</strong> creates the SOAP headers that we will pass to the SoftLayer API; this is the most complicated method in the model. Understanding how SOAP is formed and how to get the correct output from php is the key to access SoftLayer’s API. On line 77, you will see an array called Headers, this will store the headers that we are about to make so that we can easily pass them along to the API Client.</p>
<p>First we will need to create the initial headers to communicate with SoftLayer’s API. This is what they should look like:</p>

<div class="wp_syntax"><div class="code"><pre class="nolang" style="font-family:monospace;">&lt;authenticate xsi:type=&quot;slt:authenticate&quot; xmlns:slt=&quot;http://api.service.softlayer.com/soap/v3/SLTypes/&quot;&gt;
    &lt;username xsi:type=&quot;xsd:string&quot;&gt;MY_USERNAME&lt;/username&gt;
    &lt;apiKey xsi:type=&quot;xsd:string&quot;&gt;MY_API_ACCESS_KEY&lt;/apiKey&gt;
&lt;/authenticate&gt;
&lt;SoftLayer_API_METHODInitParameters xsi:type=&quot;v3:SoftLayer_API_METHODInitParameters&quot; &gt;
    &lt;id xsi:type=&quot;xsd:int&quot;&gt;INIT_PERAMETER&lt;/id&gt;
&lt;/SoftLayer_API_METHODInitParameters&gt;</pre></div></div>

<p>In order to build this we will need a few saved properties from our instantiated object: our api username, api key, the service, initialization parameters, and the SoftLayer API type namespace. The api username and key will need to be set by the controller, or you can add in yours to the model to use as a default. I will store mine in a separate file and include it in the controller, but on a production server you might want to store this info in a database and create a &#8220;user&#8221; model. </p>
<p>First, we instantiate SoapVar objects for each authentication node that we need. Then we store the SoapVar objects in an array and create a new SoapVar object for the &#8220;<code>authenticate</code>&#8221; node. The data for the &#8220;<code>authenticate</code>&#8221; node is the array, and the encoding is type <code>SOAP_ENC_OBJECT</code>. Understanding how to nest SoapVar objects is the key to creating well formed SOAP in PHP. Finally, we instantiate a new SoapHeader object and append that to the Headers array. The second header we create and add to the Headers array is for initialization parameters. These are needed to run certain methods within SoftLayer’s API; they essentially identify objects within your account. The final command in this method (<code>__setSoapHeaders</code>) is the magical PHP method that saves the headers into our SoapClient object. Now take a look at how I access the method; because I have stored the SoapClient object as a property of the current class I can use the arrow operator to access methods of that class through the <code>$_client</code> property of our class, or the <code>getClient()</code> method of our class which returns the client.</p>
<p><strong>The Response method</strong> is the action which actually contacts SoftLayer’s API and sends our SOAP request. Take a look at how I tell PHP that the string stored in our <code>$_method</code> property is actually a method of our $_client property by adding parenthesis to the end of the <code>$Method</code> variable on line 71.</li>
</ul>
</li>
</ul>
<p><strong>View</strong><br />
The view is what the user interprets, this is where we present our information and create a basic layout for the web page. Take a look at &#8220;The View&#8221; section on <a href="http://blog.softlayer.com/soap-api-code-examples/">SOAP API Code Examples</a>. Here I create a basic webpage layout, display output information from the controller, and create a form for sending requests to the controller. Notice that the View is a mixture of HTML and PHP, so make sure to name it view.php that way the server knows to process the php before sending it to the client. </p>
<p><strong>Controller</strong><br />
The controller separates user interaction from business logic. It accepts information from the user and formats it for the model. It also receives information from the model and sends it to the view. Take a look at &#8220;The Controller&#8221; section on <a href="http://blog.softlayer.com/soap-api-code-examples/">SOAP API Code Examples</a>. I accept variables posted from the view and store them in an array to send to the model on lines 6-11. I then instantiate the <code>$Call</code> object with the parameters specified in the <code>$Setup</code> array, and store the response from the Response method as <code>$Result</code> in line 17 for use by the view.</p>
<p><strong>Have Fun!</strong><br />
Although this tutorial seems to cover many different things, this just opens up the basic utilities of SoftLayer&#8217;s API. You should now have a working View to enter information and see what kind of data you will receive. The first service and method you should try is the <code>SoftLayer_Account</code> service and the <code>getObject</code> method. This will return your account information. Then try the <code>SoftLayer_Account</code> service and the <code>getHardware</code> method; it will return all of the information for all of your servers. Take the IDs from those servers and try out the <code>SoftLayer_Hardware_Server</code> service and the <code>getObject</code> method with that <code>id</code> as the <code>Init</code> property. </p>
<p>More examples to try: <a href="http://sldn.softlayer.com/wiki/index.php/SoftLayer_Account">SoftLayer Account</a>, <a href="http://sldn.softlayer.com/wiki/index.php/SoftLayer_Dns_Domain">SoftLayer DNS Domain</a>, <a href="http://sldn.softlayer.com/wiki/index.php/SoftLayer_Hardware_Server">SoftLayer Hardware Server</a>. Once you get the hang of it, try adding <a href="http://sldn.softlayer.com/article/Using-Object-Masks-SoftLayer-API">Object Masks</a> and <a href="http://sldn.softlayer.com/article/Using-Result-Limits-SoftLayer-API">Result Limits</a> to your model.</p>
<p>Have Fun!</p>
<p>-Kevin</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/softlayer-soap-api-application-development-101/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modern Website Design: Layout</title>
		<link>http://blog.softlayer.com/2011/modern-website-design-layout/</link>
		<comments>http://blog.softlayer.com/2011/modern-website-design-layout/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 13:40:06 +0000</pubDate>
		<dc:creator>Kevin Trachier</dc:creator>
				<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[recommendation]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/2011/</guid>
		<description><![CDATA[There have been many books written about website design, and I am not about to take on the challenge of disputing any of them or trying to explain every facet of design. In this short blog, I want to explain what I have come to understand as the modern layout of websites. The term &#8220;layout&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>There have been many books written about website design, and I am not about to take on the challenge of disputing any of them or trying to explain every facet of design. In this short blog, I want to explain what I have come to understand as the modern layout of websites. The term &#8220;layout&#8221; may have many different definitions, but for this article I am talking about the basic structure of your website, meaning <a href="http://en.wikipedia.org/wiki/Separation_of_concerns">separation of concerns</a>, data transfer from host to client, how to handle changes in data, and when to change your page structure.</p>
<h3>Separation of Concerns</h3>
<p>It is important when sitting down for the first time to build a website to come up with an outline. Start by making a list of the parts of your website and the functions of those parts. I always start at the base of my web structure and work from there. HTML is always the foundation of a website; it defines the structure and outlines how you will display your data &ndash; plain and simple. It doesn&#8217;t have to include data or styles, nor does it need to be dynamic &#8230; At its essence, it&#8217;s a static file that browsers can cache. </p>
<p>Client-side scripting languages like JavaScript will take care of client-side animations and data dispersal, while cascading style sheets (CSS) take care of style and presentation, and server-side scripting languages like <a href="http://en.wikipedia.org/wiki/PHP">PHP</a> or <a href="http://en.wikipedia.org/wiki/Perl">Perl</a> can take care of data retrieval and formatting.</p>
<h3>Data Transfer</h3>
<p>Where is your data going to come from, and what format it will be in when the client receives it? Try to use a data format that is the most compatible with your scripting languages. I use JavaScript as my primary client side scripting program, so I try to use <a href="http://www.json.org/">JSON</a> as my data format, but that&#8217;s not always possible when dealing with APIs and transferring data from remote computers. JSON is quickly becoming a standard data format, but <a href="http://en.wikipedia.org/wiki/XML">XML</a>* is the most widely accepted format.</p>
<p>I prefer to use <a href="http://blog.softlayer.com/2011/api-basics-rest/">REST APIs</a> as much as possible, because they sends the information directly on the client, rather than using the server as a proxy. However, if a REST API is not available or if there is a security risk involved, you get the advantage of being able to format the data on the server before pushing it to the client. Try to parse and format data as little as possible on the client side of things, the client should be concerned with placing data.</p>
<h3>Changes in Data</h3>
<p>In the past, websites were made from multiple HTML documents, each one containing different data. The structure of the pages were the same though, so the data changed, but the code was nearly identical. Later, using server side scripting programs, websites became more dynamic, displaying different data based on variables passed in the URL. Now, using AJAX or <a href="http://blog.softlayer.com/2011/ajax-without-xml-http-requests/">script injection</a>, we can load new data into a static webpage without reloading. This means less redundant code, less load on the client, and better overall performance.</p>
<h3>Page Structure</h3>
<p>It is important when displaying data to understand when to change the structure of the page. I start by creating a structure for my home page &#8211; it needs to be very open and unrestricting so I can add pictures and text to build the site. Once the overall loose structure is established, I create a structure for displaying products (this will be more restrictive, containing tables and ordering tools). The idea is to have as few HTML structures as possible, but if you find that your data doesn&#8217;t fit or if you spend a lot of time positioning your data, then it might be time to create a new structure.</p>
<h3>The Impact of a Modern Layout</h3>
<p>Following these steps will lead to quicker, more efficient websites. This is (of course) not a new subject, and further understanding of web layout can be found in Model-View-Controller frameworks. If you find that you spend too much time writing code to interface with databases or place data, then frameworks are for you.</p>
<p>-Kevin</p>
<p>*If you have to deal with XML, make sure to include JavaScript libraries that make it easier to parse, like <a href="http://jquery.com/">JQuery</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/modern-website-design-layout/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>API Basics: REST API &#8211; &#8220;Hello World&#8221;</title>
		<link>http://blog.softlayer.com/2011/api-basics-rest-api-hello-world/</link>
		<comments>http://blog.softlayer.com/2011/api-basics-rest-api-hello-world/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 15:30:11 +0000</pubDate>
		<dc:creator>Kevin Trachier</dc:creator>
				<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/2011/</guid>
		<description><![CDATA[Learning SoftLayer&#8217;s API When I first started to look at SoftLayer&#8217;s API, I favored the SOAP programming interface because I liked the strictly formatted XML responses, the good separation of concerns (using the server as proxy for data retrieval) and the increased security. All of these are great reasons to use the SOAP interface, but [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Learning SoftLayer&#8217;s API</strong><br />
When I first started to look at SoftLayer&#8217;s API, I favored the <a href="http://blog.softlayer.com/2011/api-basics-what-is-soap/">SOAP programming interface</a> because I liked the strictly formatted XML responses, the good separation of concerns (using the server as proxy for data retrieval) and the increased security. All of these are great reasons to use the SOAP interface, but once I saw how easy and direct the <a href="http://blog.softlayer.com/2011/api-basics-rest/">REST</a> interface is, I decided that I would use it as my cornerstone for learning the SoftLayer API.</p>
<p><strong>REST API</strong><br />
Although the REST software archetype is a difficult concept to explain, its practice has become natural to those of us who use the internet daily. Imagine that the information that you want to know is saved as a web page somewhere and all you have to do is type in the URL, it will prompt you for a username and password, and you will see the information that you requested.</p>
<p><strong>Authentication</strong><br />
Before making a request you will need to find your API authentication token. To do this, log into your customer account and click API under the Support tab. Click the &#8220;Manage API Access&#8221; link. At the bottom of the next page you will see a drop-down menu that says &#8220;Select a User&#8221; and above it a tag that says &#8220;Generate a new API access key.&#8221; Select a user and click the &#8220;Generate API Key&#8221; button. You will see your username and the generated API key for that user. Copy this API key, as you&#8217;ll need it to send commands SoftLayer&#8217;s API.</p>
<p><strong>&#8220;Hello World&#8221;</strong><br />
Unfortunately, there is no specific &#8220;Hello World&#8221; command in SoftLayer&#8217;s API, but there are some commands that are very simple and don&#8217;t require any variables, like the <code>getObject()</code> method. APIs are like component libraries, split into web services and methods of that service. The <a href="http://sldn.softlayer.com/wiki/index.php/Category:API_Services">SLDN</a> has a full list of SoftLayer&#8217;s web services to choose from. I am going to use the <code>getObject()</code> method from the <code>SoftLayer_Account</code> service in this example:</p>
<p style="margin-bottom:0;"><a href="https://api.softlayer.com/rest/v3/SoftLayer_Account.xml">https://api.softlayer.com/rest/v3/SoftLayer_Account.xml</a></p>
<ul style="margin-top:0;">
<li>You will be prompted for your username and API access key</li>
<li>XML data type output</li>
</ul>
<p style="margin-bottom:0;"><a href="https://USERNAME:PASSWORD@api.softlayer.com/rest/v3/SoftLayer_Account.json">https://USERNAME:PASSWORD@api.softlayer.com/rest/v3/SoftLayer_Account.json</a></p>
<ul style="margin-top:0;">
<li>Automatic authentication</li>
<li>JSON data type output</li>
</ul>
<p><strong>The Request</strong><br />
Here is the basic REST request structure:</p>
<div style="width: 650px; height: auto; overflow:auto; border: 1px solid black;">
<pre><code>https://<u><em>username</em></u>:<u><em>API key</em></u>@api.service.softlayer.com/rest/v3/<u><em>serviceName</em></u>/<u><em>InitializationParameter</em></u>.<u><em>returnDatatype</em></u></code></pre>
</div>
<ul>
<li>All requests are sent via secure transfer (https://)</li>
<li>Listing your <code>username</code> and <code>API key</code> before the URL allows for automatic HTTP authentication</li>
<li><code>Service</code> and <code>serviceName</code> both refer to the web service you are trying to access</li>
<li><code>InitializationParameter</code> is only used if the method you are calling requires an initialization Parameter</li>
<li>SoftLayer&#8217;s REST API can respond with either JSON or XML data types; replace <code>returnDatatype</code> with the type you would like to receive.</li>
</ul>
<p><strong>The Data</strong><br />
Looking at the first link above, your browser should be able to output the response data in XML format, showing information about your account. More information about the format of the data can be found <a href="http://sldn.softlayer.com/wiki/index.php/SoftLayer_Account_%28type%29">on the SLDN wiki</a>.</p>
<p><strong>REST Basics</strong><br />
When you start integrating this into a website you will want to get/make a function or library to handle advanced requests and to properly receive and disperse the response; I recommend using JQuery. This is the most basic example of a function call for SoftLayer&#8217;s API, I hope that it will help you get a feel for the information that you will need to pass to our server and the kind of response that you will receive.</p>
<p>-Kevin</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/api-basics-rest-api-hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>API Basics: REST</title>
		<link>http://blog.softlayer.com/2011/api-basics-rest/</link>
		<comments>http://blog.softlayer.com/2011/api-basics-rest/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 14:55:37 +0000</pubDate>
		<dc:creator>Kevin Trachier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[JSONP]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/2011/</guid>
		<description><![CDATA[What is REST? &#8220;Representational State Transfer,&#8221; or REST, is a style of software architecture designed to relate different types of hypermedia to each other for distribution. The basic concept of REST is that a client application can request information from a server in the form of a representation of a resource without actually downloading an [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What is REST?</strong><br />
&#8220;Representational State Transfer,&#8221; or REST, is a style of software architecture designed to relate different types of hypermedia to each other for distribution. The basic concept of REST is that a client application can request information from a server in the form of a representation of a resource without actually downloading an entirely new resource. This is how the World Wide Web works.</p>
<p><strong>The World Wide Web</strong><br />
A browser is a client side application which requests information from a server; the server then accepts the request and transfers data back to the browser. The data transferred is not an application; it simply gives instructions to the client-side application (the browser), which then uses those instructions to properly display some information. Downloading information from a server changes the <a href="http://en.wikipedia.org/wiki/State_%28computer_science%29">application state</a> of the browser. The result of that change in state is a new website, which is therefore named the new state, so when new websites are downloaded by a browser, it is transferring representational data for a new application state.</p>
<p><strong>How does REST relate to SoftLayer&#8217;s API?</strong><br />
<a href="http://sldn.softlayer.com/wiki/index.php/The_SoftLayer_API">SoftLayer&#8217;s API</a> has many different avenues for implementation; one of these avenues is simple data transfer using the <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods">GET</a> method in <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP</a>. <a href="http://en.wikipedia.org/wiki/Hyperlinks">Hyperlinks</a> are one of the most basic examples of REST in action. When the user clicks on the hyperlink it requests information from the server and responds by transferring back representational data, in this case the data is expressed as either <a href="http://en.wikipedia.org/wiki/XML">XML</a> or <a href="http://en.wikipedia.org/wiki/JSON">JSON</a>.</p>
<p><strong>What are the disadvantages of using a REST API?</strong><br />
REST requests must contain all information, including authentication, within the <a href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URL</a>. This can lead to security threats somewhere down the line. Luckily, SoftLayer allows you to add any number of users to your account, and then restrict their access to specific servers/services. This way your customers can utilize SoftLayer&#8217;s API without a security risk to you or each other. They can even create their own users and further restrict access.</p>
<p><strong>What are the advantages of using SoftLayer&#8217;s REST API?</strong><br />
Direct client to server communication is the biggest advantage of using REST. The other protocols that SoftLayer uses to communicate data to the API require server-side scripting; this means that you will have to program your websites to use the host server as a proxy for calling SoftLayer functions. With REST you can directly link to the information that you want to display, using <a href="http://en.wikipedia.org/wiki/XLST">XLST</a> or <a href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a> to display it. You can also use <a href="http://en.wikipedia.org/wiki/Ajax">AJAX</a> with <a href="http://en.wikipedia.org/wiki/JSON#JSONP">JSONP</a> or <a href="http://blog.softlayer.com/2011/ajax-without-xml-http-requests/">script injection</a> to dynamically update your webpage.</p>
<p><strong>REST</strong><br />
The REST archetype is the most natural API for HTTP. This sets it above others in that there are no secondary programs needed to interact with HTTP (like <a href="http://blog.softlayer.com/2011/api-basics-what-is-soap/">SOAP</a>), which means less computing time and better performance. REST APIs also don&#8217;t need to use a proxy server for remote procedure calls. This decreases server load and bandwidth usage and further increases website performance. SoftLayer&#8217;s REST API is easy to implement, and with SoftLayer&#8217;s tiered user system its security flaws can be eliminated. This is why I prefer SoftLayer&#8217;s REST API over the others.</p>
<p>Basic REST function calls are detailed in the SoftLayer Development Network (SLDN) <a href="http://sldn.softlayer.com/wiki/index.php/REST#REST_URLs">here</a>.</p>
<p>-Kevin</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/api-basics-rest/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>API Basics: What is SOAP?</title>
		<link>http://blog.softlayer.com/2011/api-basics-what-is-soap/</link>
		<comments>http://blog.softlayer.com/2011/api-basics-what-is-soap/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 15:00:13 +0000</pubDate>
		<dc:creator>Kevin Trachier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[RCP]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/2011/</guid>
		<description><![CDATA[What is SOAP? &#8220;Simple Object Access Protocol&#8221; &#8211; SOAP is a method and format for sending XML from one server to another via HTTP. SOAP allows you to have remote database servers which supply information to power your website. The best part about SOAP is that it is universal and secure. This means that big [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What is SOAP?</strong><br />
&#8220;Simple Object Access Protocol&#8221; &#8211; SOAP is a method and format for sending XML from one server to another via HTTP. SOAP allows you to have remote database servers which supply information to power your website. The best part about SOAP is that it is universal and secure. This means that big companies like SoftLayer can open their databases for you to gather the information that you need to keep your customers up to date. This kind of complete transparency is what makes SOAP (and any other supported <a href="http://en.wikipedia.org/wiki/Application_programming_interface">API</a>) an invaluable asset to SoftLayer customers. In order to fully understand SOAP, you will need to know about markup languages, namespaces and a little about the protocols used to implement it.</p>
<p><strong>Markup Languages?</strong><br />
The term &#8220;markup language&#8221; is derived from when teachers/editors would make corrections to a written article, using shorthand for what needed to be corrected. A markup language is just a document with a few special symbols used to separate some text as &#8220;markup;&#8221; this text can then be used by other programs to perform tasks. Markup languages are <a href="http://en.wikipedia.org/wiki/Declarative_programming">declarative programming languages</a>, so they contain data and talk about data, but they don&#8217;t actually have instructions about what to do with the data. <a href="http://en.wikipedia.org/wiki/Hypertext_Markup_Language">HTML</a>, <a href="http://en.wikipedia.org/wiki/XML">XML</a> and <a href="http://en.wikipedia.org/wiki/LaTeX">LaTeX</a> are all variations of markup languages. </p>
<p>Markup languages can be used for all kinds of different things, but the most common markup language used in web design is Hyper Text or HTML. HTML uses predetermined markup &#8220;tags&#8221; to describe data for browsers to display; it is the basic building block of all websites. SOAP uses XML to transfer data from server to server.</p>
<p><strong>What is XML?</strong><br />
&#8220;Extensible markup language&#8221; &#8211; XML is a markup language dedicated to presenting data to different applications. Unlike HTML, XML has no dedicated markup tags; instead, you can create any type of tag you want. In XML, the tags describe and define the data that they contain. Applications can easily pull just the data that they need, no matter what is in the document. In this way an XML can be expanded without causing application errors, making it &#8220;extensible.&#8221; Due to the free form of XML tags, sometimes you want multiple tags to have the same name; this is possible with XML namespaces.</p>
<p><strong>How do XML Namespaces work?</strong><br />
Namespaces are used to group XML elements so that parsing programs won&#8217;t confuse different elements that have the same name. Namespaces have to be defined by a &#8220;universal resource identifier&#8221; or <a href="http://en.wikipedia.org/wiki/Uniform_Resource_Identifier">URI</a>; essentially, they have to be universally unique. This is why the <a href="http://en.wikipedia.org/wiki/World_Wide_Web_Consortium">WC3</a> chose to use website <a href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URLs</a> as the standard naming convention. This can lead to some confusion when looking at XML namespaces, though. Information is not transferred to or from the websites; they don&#8217;t even have to resolve, parsing programs read the URLs as basic text strings. SOAP uses a few pre-determined namespaces to define key information, but the most important thing about SOAP is its ability to work as an RPC-type protocol.</p>
<p><strong>RPC?</strong><br />
&#8220;Remote procedure calls&#8221; are connections created between two or more servers for the sole purpose of enacting programs or procedures on a remote server. <a href="http://en.wikipedia.org/wiki/Remote_procedure_call">RPCs</a> start at the client, sending a request to the remote server with a procedure name and perameters for the procedure. The request has to be in a very strict format, that way the host server doesn&#8217;t have to know anything about the language that the client is using. SOAP makes RPCs over <a href="http://en.wikipedia.org/wiki/HTTP">HTTP</a> because it is the most accessible protocol; very few firewalls block HTTP, and SOAP makes use of headers similar to <a href="http://en.wikipedia.org/wiki/List_of_HTTP_headers">HTTP headers</a> to provide encoding and security information.</p>
<p><strong>So, What is SOAP?</strong><br />
In short, SOAP is a very strictly formatted XML document which uses XML namespaces to define key elements of data, sent via HTTP, in order to enact procedures on a remote server, and sometimes receive data in response to those procedures.</p>
<p>-Kevin</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/api-basics-what-is-soap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX Without XML HTTP Requests</title>
		<link>http://blog.softlayer.com/2011/ajax-without-xml-http-requests/</link>
		<comments>http://blog.softlayer.com/2011/ajax-without-xml-http-requests/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 16:00:03 +0000</pubDate>
		<dc:creator>Kevin Trachier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/2011/</guid>
		<description><![CDATA[What is AJAX? Asynchronous JavaScript and XML &#8211; AJAX &#8211; is what you use to create truly dynamic websites. Ajax is the bridge between application and presentation layers, facilitating lightning fast, instant application of data from the end user to the host and back to the end user. It dynamically changes the data displayed on [...]]]></description>
			<content:encoded><![CDATA[<h3>What is AJAX?</h3>
<p><a href="http://en.wikipedia.org/wiki/Ajax">Asynchronous JavaScript and XML</a> &#8211; AJAX &#8211; is what you use to create truly dynamic websites. Ajax is the bridge between application and presentation layers, facilitating lightning fast, instant application of data from the end user to the host and back to the end user. It dynamically changes the data displayed on the page without disrupting the end user or bogging down the client. Although the name is misleading, it is used as a term for any process that can change the content of a web page without unnecessarily reloading other parts of the page.</p>
<h3>What are XML HTTP requests?</h3>
<p>Passing information from your server to your end user&#8217;s browser is handled over <a href="http://en.wikipedia.org/wiki/HTTP">HTTP</a> in the form of <a href="http://en.wikipedia.org/wiki/HTML">HTML</a>. The browser then takes that info and formats it in a way the end user can view it easily. What if we want to change some of the data in the HTML without loading a whole new HTML document? That&#8217;s where XML comes in. Your web page needs to tell the browser to ask for the XML from the server; luckily, all browsers have a function called <code><a href='http://en.wikipedia.org/wiki/XMLHttpRequest'>XmlHttpRequest()</a></code>. Once it&#8217;s called, it will poll the server for XML data.</p>
<h3>Why shouldn&#8217;t you use XML HTTP requests?</h3>
<p>A long time ago, in a galaxy far, far away, Microsoft invented the <code>XmlHttpRequest()</code> object for Microsoft Exchange Server 2000. As with all first generation technologies, everyone wanted to use it, and some people implemented it differently. IE didn&#8217;t even have native support until 2006, and there are still some discrepancies in various browsers when studying the <code><a href="http://en.wikipedia.org/wiki/XMLHttpRequest#The_onreadystatechange_event_listener">OnReadyStateChange</a></code> event listener. There is also an issue with <a href="http://en.wikipedia.org/wiki/XMLHttpRequest#Cross-domain_requests">cross-domain requests</a>. When the internet was young, JavaScript hackers would steal users&#8217; identity by pulling information from secure websites and posting it to their own, stealing bank account numbers, credit cards, etc. Now that the internet has grown up a bit, people with large networks and many servers have found use for sending data across domains, but it&#8217;s still not possible with XML HTTP requests.</p>
<h3>What&#8217;s an Alternative?</h3>
<p>Using JavaScript, you can create client side scripts whose source is built with server side scripts, passing variables in the URL. Here&#8217;s an example of a basic web page with local JavaScript, a few checkboxes for human interaction, and a table with some information that we want to change. View source on the page <a href="http://64.246.2.254/Examples/example.html">below</a> to see the outline.</p>
<p><iframe src="http://64.246.2.254/Examples/example.html"></iframe><br/></p>
<p>Looking at the three JavaScript functions, the first (<code>clearTags</code>) automatically clears out the checkboxes on load, the second (<code>check(box)</code>) makes sure that only one box is checked at a time, the third (<code>createScript</code>) is the interesting one; it uses the <code>createElement()</code> function to create an external JavaScript, the source of which is written in PHP. I have provided a sample script below to explain what I mean. First, we get the variable from the URL using the <code>$_GET</code> super global. Then, we process the variable with a switch, but you might use this opportunity to grab info from a database or other program. Finally, we print code which the browser will translate to JavaScript and execute.</p>
<div style="width: 650px; height: auto; overflow:auto; border: 1px solid black;">
<pre><code>&lt;?PHP
//First we get the variable from the URL
$foo=$_GET['foo'];
//Here's the switch to process the variable
switch ($foo){
case 'foo' : print "var E=document.getElementById('data'); E.innerHTML='bar'; "; break;
case 'fooo' : print "var E=document.getElementById('data'); E.innerHTML='barr'; "; break;
case 'ffoo' : print "var E=document.getElementById('data'); E.innerHTML='baar'; "; break;
case 'ffooo' : print "var E=document.getElementById('data'); E.innerHTML='baarr'; "; break;
default : print "var E=document.getElementById('data');
E.innerHTML='unknown'; ";
}
?&gt;
</code></pre>
</div>
<p>-Kevin</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/ajax-without-xml-http-requests/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
