XML-RPC in ASP.NET MVC

I know there is a .NET library for using XML-RPC, but does anyone know if it can be used in ASP.NET MVC or not?

+5
source share
6 answers

The culinary computing library xml-rpc.net can be used with any ASP.NET project, including ASP.NET MVC.

http://xml-rpc.net/

+4
source

XML-RPC.NET can be used with ASP.NET MVC.

Define an interface for the XML-RPC service, for example:

using CookComputing.XmlRpc;

public interface IStateName
{
  [XmlRpcMethod("examples.getStateName")]
  string GetStateName(int stateNumber);
}

Implement the service:

using CookComputing.XmlRpc;

public class StateNameService : XmlRpcService, IStateName
{
  public string GetStateName(int stateNumber)
  {
    if (stateNumber < 1 || stateNumber > m_stateNames.Length)
      throw new XmlRpcFaultException(1, "Invalid state number");
    return m_stateNames[stateNumber - 1];
  }

  string[] m_stateNames
    = { "Alabama", "Alaska", "Arizona", "Arkansas",
        "California", "Colorado", "Connecticut", "Delaware", "Florida",
        "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", 
        "Kansas", "Kentucky", "Lousiana", "Maine", "Maryland", "Massachusetts",
        "Michigan", "Minnesota", "Mississipi", "Missouri", "Montana",
        "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", 
        "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma",
        "Oregon", "Pennsylviania", "Rhose Island", "South Carolina", 
        "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", 
        "Washington", "West Virginia", "Wisconsin", "Wyoming" };
}

Implement your own route handler:

using System.Web;
using System.Web.Routing;

public class StateNameRouteHandler : IRouteHandler
{
  public IHttpHandler GetHttpHandler(RequestContext requestContext)
  {
    return new StateNameService();
  }
}

Register your custom route in global.asax.cs:

public static void RegisterRoutes(RouteCollection routes)
{
  routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

  routes.Add(new Route("api/statename", new StateNameRouteHandler()));

  // ...

}

, , URL- , , http://localhost:33821/api/statename Visual Studio. . , XML-RPC .

+7

- ( XML RPC MVC ).

, , , , , MVC , , " ". XML- RPC ( - ?) - asmx.

RPC- WCF XML ( ) - Live Writer. MVC .

, ActionFilters, Factory, ModelBinder () XML Rpc ..; XML RPC .

, - :)

+2

.NET, ASP.NET MVC. ASP.NET MVC- - .NET Framework, , .NET, ASP.NET MVC.

+1
+1

"XmlRpcMvc", 2011 . GitHub. , ;)

It is also available through NuGet: Install-Package XmlRpcMvc ( MetaWeblog Example )

+1
source

All Articles