XPC - Xtended Procedure Call
I was learning XML-RPC and found it cumbersome, limited and outdated.
No intention to dethrone it or to demerit the author's good intentions, neither to reinvent the wheel.
This specs are just pure fun and mental excercise. I love simplicity.
Starting with a simple sample, let's say that we want to get the server's time:
<request>
<call method="GetSystemTime" />
</request>
This is what we get:
<response>
<var>2004/01/01T08:25:15</var>
</response>
Ashtonishingly simple huh?
As you can see, we only need to pass the name of the method and we get back the result.
Now, We could also pass the class and library where the method resides and some parameters like:
<request>
<call library="Math" class="Samples" method="Subtract">
<var type="int">5</var>
<var type="int">3</var>
</call>
</request>
Then the first rules would be:
- Without library and class, the method is a system method.
- Without library, the class must be instantiated and then the method called
- With all parts of the call present, we know in what library the class resides and what method to call.
In the COM world we instantiate "Library.Class" then we call "method"
In the .NET world we load the "assembly", then instantiate the "class" then call the "method".
In the java world? Opinions wanted.
Note: We could have an internal referencial list of public libraries and classes so the caller would provide only the class and method and we could infer the library.
Or just the method name and infer the library and class if the method is unique.
Opinions?
Unfortunately, in order to comprehend the big differences between both specs we have to compare them, let's see:
XML-RPC:
<?xml version="1.0"?>
<methodCall>
<methodName>examples.getStateName</methodName>
<params>
<param>
<value>
<i4>41</i4>
</value>
</param>
</params>
</methodCall>
XPC:
<?xml version="1.0"?>
<request>
<call method="examples.getStateName">
<var type="int">41</var>
</call>
</methodCall>
Note: From now on, for clarity's sake we will ommit the ?xml directive.
Ready for the response?
XML-RPC:
<methodResponse>
<params>
<param>
<value>
<string>South Dakota</string>
</value>
</param>
</params>
</methodResponse>
XPC:
<response>
<var type="string">South Dakota</var>
</response>
What if we get an error?
Let's see:
XML-RPC:
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value>
<int>4</int>
</value>
</member>
<member>
<name>faultString</name>
<value>
<string>Too many parameters.</string>
</value>
</member>
</struct>
</value>
</fault>
</methodResponse>
Wow, that was a mouthful.
Be prepared, sudden exposure to simplicity can be shocking:
XPC:
<response>
<error code="4">Too many parameters.</error>
</response>
Hmm, shocking indeed.
To be continued...