dominoGuru.com
Your Development & Design Resource
MDS Push Confirmation, Custom HTTP Headers, and a LotusScript and Java HTTP Request Consumer
04/29/2010 05:55 PM by Chris Toohey
Today I updated Showtime, my BlackBerry Enterprise Server MDS Push Utility for the
IBM Lotus Notes Client, to use the
X-RIM-Push_NotifyURL
HTTP
Header to create a confirmation logger for any Showtime job submission...
Well, that's an over-simplification of what's happening.
When Showtime initiates an HTTP Request (via the POST Method) to the target
BlackBerry Enterprise Server MDS Push API, it generates a simple log
NotesDocument tracking who initiated the request, the Destination
,
etc. -- pretty simple stuff there.
What it could not do, however, was confirm that the request was accepted by
the MDS Push API and -- more importantly -- that the MDS Push actually pushed
the Browser, Message, Channel, or Channel-Delete job to the
Destination
.
When working with an enterprise-level solution, "I dunno, it should'a worked!" just don't cut it!
After hitting the Push applications for the BlackBerry
Enterprise Server - Development Guide (Warning: PDF), I discovered the
X-RIM-Push_NotifyURL
HTTP Header.
The idea behind X-RIM-Push_NotifyURL
is simple: upon completion
of the given MDS Push API request, the MDS Push engine will initiate an HTTP
Request (via the POST Method) to the URL defined in the
X-RIM-Push_NotifyURL
HTTP Header.
So I updated first the Showtime Preferences Form to include an option that
will allow you to specify a Notify URL value, and then updated the
doPost
Java Method in Showtime's showtime
Java Script
Library:
PreferencesDocument.
getItemValueString("x_rim_push_notifyurl")
);
At first pass, I created a simple LotusScript Agent:
Dim s As New NotesSession
Dim doc As NotesDocument
Set doc = s.Currentdatabase.Createdocument()
Call s.Documentcontext.Copyallitems(doc, true)
Call doc.Replaceitemvalue("form", "document")
Call doc.Save(True, False, False)
End Sub
But then I remembered that LotusScript ain't gonna help me when I eventually XPage-enable Showtime! So I created a duplicate Java Agent:
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
Document doc = session.getCurrentDatabase().createDocument();
session.getAgentContext().getDocumentContext().copyAllItems(doc, true);
doc.replaceItemValue("form", "document");
doc.save();
} catch (Exception e) {
e.printStackTrace();
}
}
}
I put these Agent Design Elements into a NotesDatabase residing on a Domino server, put the full URL to the Java Agent in the Showtime Preferences Notify URL, and kicked off a few jobs.
Success!
The MDS Push Engine was initiating an HTTP Request (via the POST Method) to
my defined japi
Java Agent Design Element, which consumed the
request and created NotesDocuments for review!
This new feature will -- of course -- make it into the next release of Showtime, which I hope to get out soon. Since I find myself working on this more and more, is there anything else you would like to see in the next release? Leave requests in the comments to this post and I'll see what I can do!