HTTP request consumer in XPages

Chris Toohey recently posted an example of a simple HTTP request consumer using a traditional (classic) Lotus Notes/Domino agent. I had a need for a similar solution in XPages – and since Chris never posted his follow-up post on the XPages version I had to do it myself 🙂

The HTTP request consumer is used by a 3rd party callback service to report back the status of (in my case) a HTTP form post submitted earlier by my app to that service.

The XPages solution is a simple XPage that uses the afterRenderResponse event to gather fields returned and display a related response to the user – including displaying a useful error message to the user in case the callback service misses important fields. The HTTP request parameters (form fields) are retrieved using param.get(‘<field>’). The HTTP request parameters can be GET parameters (e.g. http://hostname.com?p1=v1&p2=v2) or POST parameters.

Basic code example for the afterRenderResponse event:

try {

var exCon = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = exCon.getResponse();
response.setContentType(“text/html”);
writer.write(“” + “\n”);
writer.write(“” + “\n”);
writer.write(“” + “\n”);
writer.write(“” + “\n”);

// Read the HTTP request parameters
var _param1 = param.get( ‘test1’ );
var _param2 = param.get( ‘test2’ );

// then do whatever is needed with the HTTP request parameters – e.g. print the contents of the parameters in the response.
writer.write(“<p>Parameter 1: ” + _param1 + “</p>\n”);
writer.write(“<p>Parameter 2: ” + _param2 + “</p>\n”);

writer.write(“” + “\n”);
writer.write(“” + “\n”);
writer.endDocument();
facesContext.responseComplete();

} catch(e) {

_dump(e);

}

My first two months as self-employed consultant

This is a followup to my first two weeks as self-employed consultant at PHL Consult.

2 months have now passed since I started as full-time consultant at PHL Consult – and I am really enjoying it! It has been exciting to focus on my own business and see the immediate results of actions that I take. I have been in discussions with several potential customers and potential business partners about projects where I can offer my services. Some of these discussions has turned into real work for me and I am happy to say that I now have more than just the one customer I started with 2 months ago. The new customers and new projects are primarily focused around Domino administration (setting up new servers, upgrading existing servers) and around modern web development using XPages.

Almost all of my meetings with new and potential customers have been set up through my social network. This really shows that networking is very important for establishing business contacts. One customer, however, contacted me because they found PHL Consult through a Google AdWords ad when using Google to search for a Lotus Domino consultant. I have set up some Google AdWords ads because Google sent me a free trial of ads for $100. So maybe I should consider using AdWords when my free trial has been spent.

Starting a full-time business also require that I take care of administrative tasks. I have had meetings with my accountant to discuss the structure of my business and have decided to go with a one-man business setup (instead of setting up for instance a limited liability company). I have also talked with insurance companies in order to establish necessary company insurances to cover professional liability and business property such as my IT hardware.

I participated in the 44th DanNotes Lotus user group conference in early November. It was great to meet many of the Danish Lotus customers, Lotus business partners and Lotus consultants. I am also still an active member of the Danish Notesnet group of Lotus specialists.