SOAP, XML-RPC, and REST

We’ve been talking for a couple of days now in our information architecture class about Service Oriented Architecture (SOA). Although SOA isn’t exclusively based around web services, web services play an important role. So far, we’ve only discussed SOAP web services in class, but I’d like to talk about some of the other popular web services protocols, xml-rpc, and REST. I’m going to start with the most simple web service and work my way to the more complicated.

REST – stands for Representational State Transfer (wikipedia reference) but that’s not really that important. Basically, REST web services consist of using plain old HTTP to make method calls and you get XML back. The true RESTful way is to use GET, POST, PUT, and DELETE calls to access CRUD (Create, Read, Update, Delete) operations on an object. In that light, a GET request is your “Read,” POST is your “Create,” PUT is your “Update,” and DELETE is your “Delete” operation. Any parameters are sent as normal http parameters, either in the query string of a GET request, or in the query string of a POST request.

While the use of the above HTTP methods are ideal for this kind of web services interactions, it’s not commonly practiced. Rails is the first framework that I’ve seen that is doing any serious development and seamless support for this type of web services integration with its Active Resources library. It doesn’t come standard in Ruby on Rails, but you can get it as a plug-in.

There are a ton of web services out there that offer a REST like web services interface. They all just don’t adhere to the GET, POST, PUT, standards. They are more like xml document requests via GET or POST. For example, Yahoo! has a handful of web services that you can access via REST, including its Answers, Local, and Flickr services.

REST style web services are what power AJAX applications. The browser makes a request to a REST web service via JavaScript’s XMLHttpRequest object. The browser then parses the xml and replaces elements in the page with the data.

REST is really quite simple. If you would like to connect to some REST web services, check out my previous post on resources to help you connect to web services.

XML-RPC – is a remote procedure call protocol which uses XML for marking up both requests and responses (see wikipedia’s reference). It was created by Dave Winer of UserLand Software and Microsoft. UserLand was one of the early providers of blogging software, and thus XML-RPC is commonly used for blog ping services such as Technorati and Ping-o-Matic.

XML-RPC protocol is really simple. You pass requests which contain the method name, and parameters wrapped in xml that defines their data types. The response comes back with similar data.

XML-RPC servers are easier to implement than SOAP when using scripting languages such as php which have very loose data typing. Php has a nice PEAR library that you can install and use to handle XML-RPC client and server scripting. Ruby on Rails has built-in support for creating and connecting to xml-rpc web service. I’m sure there are other nice tools for the other languages that help you seamlessly connect to and create XML-RPC web services. If anyone knows of any good libraries, please comment.

According to wikipedia, XML-RPC is the predecessor to SOAP, which took XML-RPC to a more complex level.

SOAP – stands for Simple Object Access Protocol (see wikipedia’s reference). Accessing a SOAP web service is super easy with any language that has SOAP libraries to help you. All you have to do is point your code to the url of the web service’s WSDL, and you’re off and running, making remote calls as you would to a local object.

SOAP begins to be not so simple when you pull back the curtains and look at the innards that make it all work. Reading or creating a WSDL document is not an easy task. However, I’ve written a tutorial on how to get a SOAP server with php5.

PHP5 has a SOAP library that will handle your client and server, but you have to create your own WSDL. I’ve seen a few SOAP servers implemented using NuSOAP, a php library, but there is rarely a wsdl provided, and it can only be connected to by other NuSOAP clients from what I can tell.

Ruby on Rails has SOAP client and server capabilities, and doesn’t make you write your wsdl by hand. BenRobb has written a post on how to set up your web service in Rails.

I don’t have any experience creating SOAP servers in .NET, but I hear it is super slick. Java has a plethora of tools for doing SOAP. While I am comfortable programming in Java and I understand basic J2EE principles, I don’t have much experience with Java web services either.

Side By Side – Flickr gives some good examples of what a request and response would look like for each of these web services.

SEO and Wikipedia

Last week, as we talked about search engine optimization in our web analytics class, someone mentioned that they had gained some good page rank from linking to relative articles from Wikipedia. This will no longer work. I’m not sure when the change was made, it may have been made a long time ago, but Blake Snow brought to my attention that Wikipedia uses the rel=”nofollow” attribute in the external link tags.

Using rel=”nofollow” in external link tags has been common practice for a long time in blog and bulletin board software. So, if you want to increase incoming links to your site, don’t count on using wikipedia, comments on blogs, forum messages, and the like. If you look at the page source you will likely find the rel=”nofollow” attribute in outgoing links.

Getting links to your site is a challenging thing. Like Blake says, the best way to get legitimate links to your site is to write some good content. My most linked-to blog posts have been the ones I’ve spent the most time on.

UK Get A Mac Commercials

I just discovered that Apple has UK versions of the Get A Mac commercials. There’s something about the British accent and lingo that makes these extra funny. My favorite is the “Office at Home” commercial.

Anyways, I’m still stuck on a PC, but have been dieing to get a mac for about 3 years now. We’re saving up for a Mac, so I’ll probably get one as a graduation present. I’m still not sure whether I want a high-end Mac Book, or a smaller Mac Book Pro. Does anyone have any advice for me on this?

As soon as I’ve got an Internet connection that gives me a public IP address, I’ll probably get a Mac Mini to host my files and act as a small web server.

Analytics by Log Files

In my Web Analytics class, we’re beginning to analyze Apache log files to extract Analytics data. Today, I pulled down a raw access log from this site to see what I could learn. I also have AWStats going to build reports for server access. As I’ve been digging through my access log, I’ve noticed that comment spammers make up a large portion of my server access.

I have found that comment spambots will hit a page on my blog, then scrape the page for the comments form, and then post spam comments to the form target. From AWStats, close to 50% of the access of my site are from Operating Systems that are unknown. This leads me to believe that about 50% of my access log data is pollution from spambots.

Luckily, spambots don’t usually download my Google Analytics JavaScript and execute it like a normal browser so the data is more pure.

Resources to help you connect to web services

The first time I was required to connect to a web service, I had no idea where to start, and ended up doing things the hard way. I needed to connect to a REST like web service in order to process a credit card transaction. I was coding in php at the time, and created all of my http headers from scratch and sent my request using fsockopen and very low-level function calls. Well, there’s a much easier way to do things. Here are some resources to help you connect to web services.

If you’re programming in Ruby, php, C#, VB.NET, ActionScript, JavaScript, or Python, then the Yahoo! Developer Network has some great resources for you. The gurus at Yahoo! have provided code samples and links to libraries that will help you connect to RESTful and SOAP web services.

If you’ve never connected to a web service before, it is really easy! Yahoo has some cool web services to try out, so have at it!

Web Services Help for:

Editing the BYU eBusiness Wiki

We’ve been required in our Web Analytics class to contribute to the BYU eBusiness Wiki. I took the topic of Risks of E-Business, but more specifically mitigating risks in E-Business. The page I contributed to is found at http://ebusiness.byu.edu/wiki/index.php?title=Mitigating_Risks.

Contributing to a University’s wiki has been somewhat stressful, as my contribution is being graded. Unlike Wikipedia, this wiki is less likely to be edited by other contributors, so what I have written will most likely stand there for a long period of time.

It has been a good experience to become more acquainted with wiki syntax and actually gain some wiki contribution experience.