Represents the response to an XML Remote Procedure Call (XML-RPC) request.

Namespace:  Argotic.Core.Net
Assembly:  Argotic.Core (in Argotic.Core)
Version: 2007.3.0.0 (2007.3.0.0)

Syntax

C#
[SerializableAttribute]
public class XmlRpcResponse : IComparable
Visual Basic (Declaration)
<SerializableAttribute> _
Public Class XmlRpcResponse _
	Implements IComparable
Visual C++
[SerializableAttribute]
public ref class XmlRpcResponse : IComparable

Remarks

XML-RPC is a Remote Procedure Calling protocol that provides simple cross-platform distributed computing based on the standards of the Internet.

A method response can not contain both a Fault and a Parameter. This class enforces this restriction by only allowing response state to be modified via the overloaded class constructor.

See http://www.xmlrpc.com/spec for more information on the XML-RPC protocol specification.

Examples

The following code example demonstrates the usage of XmlRpcResponse.
CopyC#
using System;
using System.Text;

using Argotic.Core.Net;

namespace Argotic.Test
{
    public class XmlRpcResponseCS
    {
        public XmlRpcResponseCS()
        {
            //------------------------------------------------------------
            //    Initialize the XML-RPC client
            //------------------------------------------------------------
            XmlRpcClient client         = new XmlRpcClient();
            client.Timeout              = TimeSpan.FromSeconds(10);

            //------------------------------------------------------------
            //    Define the XML-RPC message to send
            //------------------------------------------------------------
            XmlRpcMessage message       = new XmlRpcMessage();
            message.Encoding            = Encoding.UTF8;
            message.UserAgent           = "Frontier/5.1.2 (WinNT)";
            message.MethodName          = "examples.getStateName";

            XmlRpcParameter parameter   = new XmlRpcParameter();
            parameter.ParameterType     = XmlRpcParameterType.Integer;
            parameter.Value             = 41;
            message.Parameters.Add(parameter);

            //------------------------------------------------------------
            //    Send the XML-RPC message
            //------------------------------------------------------------
            XmlRpcResponse xmlRpcResponse;

            Uri xmlRpcServiceHost       = new Uri("betty.userland.com/RPC2");
            xmlRpcResponse              = client.Send(xmlRpcServiceHost, message);

            //------------------------------------------------------------
            //    Determine if remote procedure call was sucessful
            //------------------------------------------------------------
            if(xmlRpcResponse.HasFault)
            {
                //------------------------------------------------------------
                //    Get reason provided for remote procedure call failure
                //------------------------------------------------------------
                int faultCode       = xmlRpcResponse.FaultCode;
                string faultReason  = xmlRpcResponse.FaultReason;
            }
            else
            {
                //------------------------------------------------------------
                //    Get response to the remote procedure call failure
                //------------------------------------------------------------
                XmlRpcParameter responseParameter   = xmlRpcResponse.Parameter;

                if(responseParameter.ParameterType == XmlRpcParameterType.String)
                {
                    string value    = responseParameter.Value.ToString();
                }
            }
        }
    }
}

Inheritance Hierarchy

System..::.Object
  Argotic.Core.Net..::.XmlRpcResponse

See Also