Development #soap#xml#xml rpc 3 min

SOAP vs XML-RPC

Translation of the original in Catalan. Read it in: CatalàCastellano

Before starting, an important detail about the XML world, be careful not to end up like the one in the photo:

xml.jpg
</body>

Well then, we're looking at two protocols of the RPC type (Remote Procedure Control), that is, they serve to interconnect two processes that are running on dispersed systems. If you've ever taken Operating Systems, they've surely made you do the typical Unix RPC exercise programmed in C. The one that tends to be every computer science and telecommunications student's nightmare. Well, relax, since that initial theory about RPC a lot has been learned.

In fact, I've been using XML-RPC for a long time to implement simple web-services between my applications. There's a protocol that is widely used in the blogging world, it's called ping (not the usual one for checking whether a system is alive). Basically what ping does is take advantage of XML-RPC to notify another web service of an event on our web, specifically that we have updated the blog. XML-RPC is also used to do trackback between articles on different blogs. That way we can inform another blog that we have talked about that article they wrote. Notice that all this is independent of the operating system, the web server, the application, etc.

As you can see XML-RPC is very widespread and is really very useful and simple to use in all these applications I'm telling you about. Therefore, we could say that XML-RPC is aimed at simplicity and ease of use, it allows passing data between processes by encoding it in XML and using HTTP as the transport protocol. The data model that XML uses to implement XML-RPC is very simple and if you look at an HTTP-POST that carries an XML-RPC transaction you'll see that it is very simple to understand the data structures that are built from the typical tags.

soap.gif

Then you'll ask; if XML-RPC works so well why on earth do I want SOAP, or even; what on earth is SOAP. Well, the Simple Object Access Protocol (SOAP) is an RPC protocol as I already said and it is also encoded in XML and transported over HTTP, and I'll tell you even more, it also serves to transport structured information inside it. The essential difference is that it is capable of transporting fairly complex data structures and it also allows defining against which method of which class these structures have to be used. So SOAP lets us offer an infinite number of services in a single service biding (publication).

As you can see the essence is the same but the power is quite different. SOAP, by supporting such complex data models, means that when we try to look at one of the XMLs it uses to make the transactions it is quite hard for us to understand what's inside. Since as soon as we complicate the data model that is going to pass through the webservice a little it becomes quite difficult to understand the heap of tags and tag attributes that are created.

Furthermore SOAP has different extensions that make it even more powerful. Basically the best known are SOAP 1.1, SOAP 1.2 and WSDL. The last one is the most used to implement WebServices, its very name already tells us this fact WSDL: Web Services Description Language. Specifically Microsoft with .NET, IBM and Sun with Java make various implementations of WSDL in order to implement WebServices in their architectures. This suits us people who like PHP perfectly, because it allows us to understand each other with ASP, JSP, servlets and other similar things from our PHP5 which already implements SOAP/WSDL support out of the box.

If you want to start playing with SOAP and PHP5, on Zend's own website you can find this document: PHP SOAP Extension. For more technical information on WSDL, the people at xml.com have a heap of documents on the subject, specifically I recommend: WSDL first and yet another one on the same thing Examining WSDL. If you already have a grip on UML it's a good idea to start looking at how WSDLs are modelled from UML, a good document to start with UML for Web Services.

Before finishing the article, if you want a serious document that resolves your doubts about the differences between XML-RPC and SOAP, above all don't miss: XML-RPC vs SOAP (local) by kate rhodes.