Related News
XML-RPC Server Using HttpListener
I've had a handful of requests from people who want to use the .Net System.Net.HttpListener class as the basis for an XML-RPC server implemented using XML-RPC.NET. Acquiring the request synchronously via the HttpListener GetContext method, the top level code could look like this:using System;using System.IO;using System.Net;using CookComputing.XmlRpc;class _{ public static void Main(string[] prefixes) { HttpListener listener = new HttpListener(); listener.Prefixes.Add("http://127.0.0.1:11000/"); listener.Start(); while (true) { HttpListenerContext context = listener.GetContext(); ListenerService svc = new StateNameService(); svc.ProcessRequest(context); } }}ListenerService is an abstract base class we will define below and StateNameService is the derived class which contains the implementation of the methods required in the XML-RPC service:public class StateNameService : ListenerService{ [XmlRpcMethod("examples.getStateName")] 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" };}The ListenerService class derives from the XmlRpcHttpServerProtocol class and so is similar in this respect to the XmlRpcService class which is used as the bass class for XML-RPC services which are hosted in ASP.NET.public abstract class ListenerService : XmlRpcHttpServerProtocol{ public virtual void ProcessRequest(HttpListenerContext RequestContext) { try { IHttpRequest req = new ListenerRequest(RequestContext.Request); IHttpResponse resp = new ListenerResponse(RequestContext.Response); HandleHttpRequest(req, resp); RequestContext.Response.OutputStream.Close(); } catch (Exception ex) { // "Internal server error" RequestContext.Response.StatusCode = 500; RequestContext.Response.StatusDescription = ex.Message; } }}The remaining code defines the ListenerRequest and ListenerResponse classes. These essentially allow us to access the .Net HttpListenerRequest and HttpListenerResponse classes via the XML-RPC.NET IHttpRequest and IHttpResponse interfaces:public class ListenerRequest : CookComputing.XmlRpc.IHttpRequest{ public ListenerRequest(HttpListenerRequest request) { this.request = request; } public Stream InputStream { get { return request.InputStream; } } public string HttpMethod { get { return request.HttpMethod; } } private HttpListenerRequest request;}public class ListenerResponse : CookComputing.XmlRpc.IHttpResponse{ public ListenerResponse(HttpListenerResponse response) { this.response = response; } string IHttpResponse.ContentType { get { return response.ContentType; } set { response.ContentType = value; } } TextWriter IHttpResponse.Output { get { return new StreamWriter(response.OutputStream); } } Stream IHttpResponse.OutputStream { get { return response.OutputStream; } } int IHttpResponse.StatusCode { get { return response.StatusCode; } set { response.StatusCode = value; } } string IHttpResponse.StatusDescription { get { return response.StatusDescription; } set { response.StatusDescription = value; } } private HttpListenerResponse response;}This sample server can then be accessed by a client implemented in the usual way:using System;using System.Collections.Generic;using System.Text;using CookComputing.XmlRpc;[XmlRpcUrl("http://127.0.0.1:11000/index/")]public interface IStateName : IXmlRpcProxy{ [XmlRpcMethod("examples.getStateName")] string GetStateName(int stateNumber);}class Program{ static void Main(string[] args) { IStateName proxy = XmlRpcProxyGen.Create<IStateName>(); string ret = proxy.GetStateName(1); }}I'll illustrate how to use the asynchronous HttpListener methods BeginGetContext and EndGetContext in a future post. I'll also add the ListenerService, ListenerRequest, and ListenerResponse classes to the next release of XML-RPC.NET.
Breaking
As XML becomes ubiquitous throughout the enterprise, it increasingly taxes the systems that must deal with it. Even though there are a wide range of hardware and software solutions coming to market that aim to alleviate XML's performance bottlenecks (See ZapThink's XML Proxies Report), many developers are nevertheless resorting to a variety of tactics to improve the performance of XML processing and transmission that are… well… creative. Many of these creative approaches simplify certain aspects of XML in order to squeeze document size, improve parser performance, and speed the mapping of XML document components to application objects.read more
Cloud Computing Expo - Fujitsu Apes HP/EDS
Evidently HP’s acquisition of EDS persuaded Fujitsu that there’s money to be made in the services sector because it’s combining its US product and service businesses under one roof to drive revenue growth and help it compete against IBM and HP. On October 1, the doors will open on a newly created Fujitsu North America Holding Inc, a consolidation – but not apparently an integration – of Fujitsu Consulting Inc, Fujitsu Computer Systems Corporation and Fujitsu Transaction Solutions Inc with a collective revenue base approaching $2 billion a year. read more
Mark Logic Secures $12.5 Million in Additional Funding
Mark Logic Corporation has announced that it has closed a $12.5 million round of financing, led by Sequoia Capital and including participation from Tenaya Capital. The capital will be used to fund the company's continued growth in sales channels, international expansion, and new vertical market development. Mark Logic operates in both North America and Europe and has over 150 customers, 120 employees, and 60 partners. Over 450 people attended the company's annual user conference held recently in San Francisco.read more
The jury’s in: Effective software delivery (The Register)
Communications and structure lead to quality Reg Reader Workshop Over the past few weeks, we’ve been running a series of articles, polls and feedback reports on the subject of software development in general, and agile development in particular. A number of major themes have evolved, notably that agility is not some kind of panacea for all software ills - indeed, in many cases it is as much ...