%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% :XML-RPC
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{XML-RPC -- počátek webových služeb}

XML-RPC (Extended Markup Language -- Remote Procedure Call) je původní protokol pro volání RPC webových služeb, který vznikl v~roce 1998. Jak již název napovídá, výměna dat mezi webovou službou a~jejím klientem probíhá ve formátu XML. Mezi výhody XML-RPC patří jednoduchost a~snadná čitelnost.



\subsection{Požadavek}

Požadavek



Following example used by attached application demonstrates calling a~remote method by XML-RPC.

\begin{verbatim}
<methodCall>
    <methodName>calculateExchangeRate</methodName>
    <params>
        <param><value><string>CZK</string></value></param>
        <param><value><string>JPY</string></value></param>
        <param><value><double>100.00</double></value></param>
    </params>
</methodCall>
\end{verbatim}

This request calls method \texttt{calculateExchangeRate} with three unnamed parameters -- two of type string and one of type double. Response for previously described request could be the following.

\begin{verbatim}
<methodResponse>
    <methodName>calculateExchangeRate</methodName>
    <params>
        <param><value><double>550.00</double></value></param>
    </params>
	</methodResponse>
\end{verbatim}

Returned XML file contains method name (for checking purpose) and a~return value. Despite of element name \texttt{params}, only one value could be returned. When severel values are to be returned, they must be stored in either an array or a~struct.

XML-RPC offers basic data types used in all common programming languages. Namely, they are int, double, boolean, string, array, struct (as used in C++ language) and date (in ISO8601 format). All data types are to be stored in element with appropriate name (ie. \texttt{boolean} for boolean type). An interesting fact is that arrays or structs could contain another arrays or structs, which enables to simulate simple object with attribute hierarchy.

XML-RPC is very simple. It is very easy to write a~handler in ones application, that would write method calls into a~XML file and send them to the server.

It could be confusing for beginner user, that element \texttt{param} must always be followed by element \texttt{value}, making it some sort of "double element". Also, as previously mentioned, method response contains return value in element \texttt{params}, that could imply that several values could be returned at once. Moreover naming returned value \texttt{param} could lead into further confusion.

\subsection{Apache XML-RPC}
\label{XML-RPC Apache}

XML-RPC library from Apache Xml Project provides fully automatic handeling of XML-RPC messages. Sadly, the library structure in version 3.1 has changed a~lot from what is described in  \cite{Web Services Essentials} and is a~lot more complicated for both understanding and usage. It is fully functional and the XML-RPC server can be set up easily (as could be seen in attached example -- \emph{XML-RPC Demonstration}, it however provides only a~little space for customizing core methods and classes.
