XML-RPC

From BC$ MobileTV Wiki
Jump to: navigation, search

eXtensible Markup Language - Remote Procedure Calls (commonly abbreviated as XML-RPC) is one of the oldest approaches to "Web Services" and Software-as-a-Service in general. It involves sending XML requests and responses containing the actual names of methods or classes to execute within a specific application. On top of basic Web Service functionality, XML-RPC was also one of the first approaches to application integration.



EXAMPLE

Snipplr, the source code and snippet repository, runs an XML-RPC endpoint as their API. It is a perfect example, because it only takes one parameter (ID of a Snipplr snippet, which you can extract from the snippet's URL, i.e. http://snipplr.com/view/49961/html5-basic-skeleton/, the Snipplr ID is 49961) and does not require any additional authentication, encryption or specific headers. Note though, that the User-Agent must be from an approved list of some kind, I just picked a random one (went with the Konqueror browser: "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)")

Request:

<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>snippet.get</methodName>
  <params>
      <param>
           <value><int>63451</int></value>
      </param>
  </params>
</methodCall>

Response:

 <?xml version="1.0" ?>
 <methodResponse>
	<params>
		<param>
			<value>
				<struct>
					<member>
						<name>id</name>
						<value>
							<string>49961</string>
						</value>
					</member>
					<member>
						<name>user_id</name>
						<value>
							<string>28145</string>

						</value>
					</member>
					<member>
						<name>username</name>
						<value>
							<string>bcmoney</string>
						</value>
					</member>
					<member>
						<name>title</name>
						<value>
							<string>HTML5 basic skeleton</string>
						</value>
					</member>
					<member>
						<name>language</name>

						<value>
							<string>HTML</string>
						</value>
					</member>
					<member>
						<name>comment</name>
						<value>
							<string>Basic HTML5 skeleton template, including jQuery, for getting up and running quickly with HTML5</string>
						</value>
					</member>
					<member>
						<name>created</name>
						<value>
							<string>2011-03-03 07:40:17</string>
						</value>
					</member>
					<member>
						<name>updated</name>
						<value>
							<string>2012-02-22 06:16:58</string>
						</value>
					</member>
					<member>
						<name>source</name>
						<value>
							<string>&lt;!DOCTYPE html&gt;
 &lt;html&gt;
 &lt;head&gt;
  &lt;meta charset=&quot;utf-8&quot; /&gt;
  &lt;title&gt;HTML5 basic skeleton&lt;/title&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.js&quot;&gt;&lt;/script&gt;
  &lt;!--[if lt IE 9]&gt;
    &lt;script src=&quot;http://html5shiv.googlecode.com/svn/trunk/html5.js&quot;&gt;&lt;/script&gt;
  &lt;![endif]--&gt;
  &lt;style type=&quot;text/css&quot;&gt;
    header, section, footer, aside, nav, article, figure, audio, video, canvas  { display:block; }
  &lt;/style&gt;
 &lt;/head&gt;
 &lt;body&gt;
  &lt;div id=&quot;wrapper&quot;&gt;
    &lt;header&gt;
      Header
    &lt;/header&gt;
    &lt;nav&gt;
      Nav
    &lt;/nav&gt;
    &lt;section id=&quot;content&quot;&gt;
      &lt;article&gt;
        Article
      &lt;/article&gt;
    &lt;/section&gt;
    &lt;aside&gt;
      Sidebar
    &lt;/aside&gt;
    &lt;footer&gt;
      Footer
    &lt;/footer&gt;
  &lt;/div&gt;   
 &lt;/body&gt;
 &lt;/html&gt;</string>
						</value>
					</member>
					<member>
						<name>tags</name>
						<value>
							<string>template html jquery CSS3 skeleton html5 </string>
						</value>
					</member>
					<member>
						<name>snipplr_url</name>
						<value>
							<string>http://snipplr.com/view/49961/html5-basic-skeleton</string>
						</value>
					</member>
				</struct>
			</value>
		</param>
	</params>
 </methodResponse>

[1]




Tools

Resources

PHP

Perl

Python

JavaScript

Java

C/C++

Objective-C


Tutorials


External Links

References

  1. XML-RPC Examples: http://www.tutorialspoint.com/xml-rpc/xml_rpc_examples.htm
  2. Creating an XML-RPC Client: http://ws.apache.org/xmlrpc/client.html
  3. Creating an XML-RPC server: http://ws.apache.org/xmlrpc/server.html

See Also

XML | JSON | Web Service | API