-
1. What Is Xmlrpc++?
XmlRpc++ is a C++ implementation of the XML-RPC protocol.
-
2. What Is Xml-rpc?
The XML-RPC protocol was designed to make remote procedure calls (RPCs) easy: it encodes data in a simple XML format and uses HTTP for communication. XML-RPC is intended to be used to implement web services and distributed applications. Check out XML-RPC for Newbies.
-
3. What Other Xml-rpc Implementations Exist?
XML-RPC implementations
-
4. Why Do We Need Another Xml-rpc Implementation (specifically Xmlrpc++)?
XmlRpc++ is designed to make it easy to incorporate XML-RPC client and server support into C++ applications. It is written in portable, extendable C++. No other libraries are required, other than your system’s socket libraries. Simple XML parsing and HTTP support are built in. It is easy to build and has a small API. There is no easier way to add remote procedure call support to a C++ application that I know of.
-
5. Why Not Use Soap (or Dce Rpc, Onc Rpc, Corba, Dcom, …)?
XML-RPC is easy, free, and fast enough for my purposes. Use the tool that best solves your problem.
-
6. What Is An Xml-rpc Server (client)?
An XML-RPC server has one or more procedures (or methods) registered, and makes those procedures available to XML-RPC clients over a network (LAN or Internet). An XML-RPC client calls one or more remote procedures provided by an XML-RPC server, and gets a result, much like calling a local procedure (function, method, etc). Arguments and results are converted to an XML format for transfer across the network.
-
7. How Do You Use Xmlrpc++ As An Xml-rpc Server?
Here is an example of a server (taken from the file test/HelloServer.cpp in the XmlRpc++ distribution) that registers a single remote procedure named Hello and listens on a port for calls to that procedure:
#include “XmlRpc.h”
using namespace XmlRpc;
// The server
XmlRpcServer s;
// The Hello method. No arguments, result is “Hello”.
class Hello : public XmlRpcServerMethod
{
public:
Hello(XmlRpcServer* s) : XmlRpcServerMethod(“Hello”, s) {}
void execute(XmlRpcValue& params, XmlRpcValue& result)
{
result = “Hello”;
}
} hello(&s); // This constructor registers the method with the server
// The port to use
const int PORT = 8080;
int main(int argc, char* argv[]) {
// Create the server socket on the specified port
s.bindAndListen(PORT);
// Wait for requests and process indefinitely (Ctrl-C to exit)
s.work(-1.0);
return 0;
}
-
8. How Does Xml-rpc.net Represent Xml-rpc Requests And Responses?
XML-RPC.NET represents an XML-RPC endpoint as a .NET interface whose methods map onto the corresponding XML-RPC methods.
For example:
using CookComputing.XmlRpc;
public struct SumAndDiffValue
{
public int sum;
public int difference;
}
[XmlRpcUrl(“https://interviewquestions.ap6am.com/sumAndDiff.rem”)]
public interface ISumAndDiff
{
[XmlRpcMethod]
SumAndDiffValue SumAndDifference(int x, int y);
}
A server implementation implements these methods. A client implementation automatically generates a proxy class which derives from the interface.
-
9. What If The Xml-rpc Struct Member Name Is Not Valid In .net?
In some cases the name of a member in an XML-RPC struct might be invalid in the .NET programming language being used. To handle this the XmlRpcMember attribute is available. This allows an XML-RPC member name to be mapped to and from a different .NET name.
For example:
public struct SumAndDiffValue
{
[XmlRpcMember(“sample.sum”)]
public int sum;
[XmlRpcMember(“sample.difference”)]
public int difference;
}
-
10. How Are Xml-rpc Arrays Represented As .net Types?
Where possible XML-RPC.NET maps XML-RPC arrays onto arrays of .NET types. Where this is not possible, for example where the members of the XML-RPC array are not of the same type, the mapping is to an instance of System.Object[].
XML-RPC.NET does not support “jagged” arrays – arrays of arrays – because these are not CLS compliant.
-
11. What If The Xml-rpc Method Name Is Not Valid In My Programming Language?
Sometimes the XML-RPC method name cannot be used as a method name in the proxy class. For example, it is common practice for XML-RPC method names to have the form namespace.methodname, such as sample.SumAndDifference In these cases a different constructor is used for the XmlRpcMethod attribute, taking a string which specifies the XML-RPC method name.
For example:
[XmlRpcUrl(“https://interviewquestions.ap6am.com/sumAndDiff.rem”)]
public interface ISumAndDiff : IXmlRpcProxy
{
[XmlRpcMethod(“sample.sumAndDifference”)]
SumAndDiffValue SumAndDifference(int x, int y);
}
-
12. How Do I Supply Authentication Credentials?
Proxy classes are derived from IXmlRpcProxy and so inherit a Credentials property. This is used where the XML-RPC server authenticates the caller. The property is used in exactly the same way as the same property of the System.Net.WebRequest class.
For example:
ISumAndDiff proxy = (ISumAndDiff)XmlRpcProxyGen.Create(typeof(ISumAndDiff));
proxy.Credentials = new NetworkCredential(“jsmith”,”password”);
SumAndDiffValue ret = proxy.SumAndDifference(2, 3);
-
13. How Do I Send Cookies With A Request?
Proxy classes are derived from IXmlRpcProxy and so inherit a CookieContainer property of type System.Net.CookieContainer, like the corresponding property of System.Net.HttpWebRequest. Instances of System.Net.Cookie added to the container will sent with the HTTP request.
For example:
ISumAndDiff proxy = (ISumAndDiff)XmlRpcProxyGen.Create(typeof(ISumAndDiff));
Cookie cookie = new Cookie(“foo”, “bar”, “/”, “interviewquestions.ap6am.com”)
proxy.CookieContainer.Add(cookie);
SumAndDiffValue ret = proxy->SumAndDifference(2, 3);
XML Interview Questions
XML Tutorial
HTML Interview Questions
HTML Tutorial
Adv Java Interview Questions
Java-Springs Interview Questions
Adv Java Tutorial
BizTalk Admin Interview Questions
XML Interview Questions
Java-Springs Tutorial