InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How Do I Send Cookies With A Request? |
|
Answer» 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", "/", "www.wisdomjobs.com") proxy.CookieContainer.Add(cookie); SumAndDiffValue ret = proxy->SumAndDifference(2, 3); 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", "/", "www.wisdomjobs.com") proxy.CookieContainer.Add(cookie); SumAndDiffValue ret = proxy->SumAndDifference(2, 3); |
|
| 2. |
How Do I Supply Authentication Credentials? |
|
Answer» 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); 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); |
|
| 3. |
What If The Xml-rpc Method Name Is Not Valid In My Programming Language? |
|
Answer» 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("HTTP://www.wisdomjobs.com/sumAndDiff.rem")] public interface ISumAndDiff : IXmlRpcProxy { [XmlRpcMethod("sample.sumAndDifference")] SumAndDiffValue SumAndDifference(int x, int y); } 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("http://www.wisdomjobs.com/sumAndDiff.rem")] public interface ISumAndDiff : IXmlRpcProxy { [XmlRpcMethod("sample.sumAndDifference")] SumAndDiffValue SumAndDifference(int x, int y); } |
|
| 4. |
How Are Xml-rpc Arrays Represented As .net Types? |
|
Answer» 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. 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. |
|
| 5. |
What If The Xml-rpc Struct Member Name Is Not Valid In .net? |
|
Answer» 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; } 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; } |
|
| 6. |
How Does Xml-rpc.net Represent Xml-rpc Requests And Responses? |
|
Answer» 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("http://www.wisdomjobs.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. 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("http://www.wisdomjobs.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. |
|
| 7. |
How Do You Use Xmlrpc++ As An Xml-rpc Server? |
|
Answer» 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; } 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. |
What Is An Xml-rpc Server (client)? |
|
Answer» 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. 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. |
|
| 9. |
Why Not Use Soap (or Dce Rpc, Onc Rpc, Corba, Dcom, ...)? |
|
Answer» XML-RPC is EASY, free, and fast enough for my purposes. USE the tool that best solves your PROBLEM. XML-RPC is easy, free, and fast enough for my purposes. Use the tool that best solves your problem. |
|
| 10. |
Why Do We Need Another Xml-rpc Implementation (specifically Xmlrpc++)? |
|
Answer» 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. 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. |
|
| 11. |
What Other Xml-rpc Implementations Exist? |
|
Answer» XML-RPC IMPLEMENTATIONS XML-RPC implementations |
|
| 12. |
What Is Xmlrpc++? |
|
Answer» XMLRPC++ is a C++ IMPLEMENTATION of the XML-RPC PROTOCOL. XmlRpc++ is a C++ implementation of the XML-RPC protocol. |
|