Wednesday, August 15, 2007

Capturing the Session ID

I'm out here in Boston visiting the PIH offices and meeting all of the OpenMRS guys from the Boston and Indianapolis offices (more on that later).

Burke and I have been trying to figure out why the forms in OpenOffice.org aren't actually HTTP POSTing the XML data to the OpenMRS server. After scratching our heads and checking the server logs, he suggested I use tcpmon to capture the data from OpenOffice to see what was going wrong.

tcpmon is pretty cool. It works by creating a sort of proxy between your localhost and another server. You give tcpmon a local port and a server and port to connect to, and it relays all of the information sent to localhost:port to server:port, capturing all of the data in between. I tried it out with my OpenMRS installation at home, and here's the result of submitting a form:
HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=AFD3B8B163899870591929C471BEE8B7; Path=/openmrs
Location: http://localhost:8084/openmrs/logout
Content-Length: 0
Date: Wed, 15 Aug 2007 13:46:45 GMT

HTTP/1.1 405 HTTP method POST is not supported by this URL
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=104147D9161F0663F217CC856D2056FE; Path=/openmrs
Content-Type: text/html;charset=utf-8
Content-Length: 1115
Date: Wed, 15 Aug 2007 13:46:45 GMT

HTTP Status 405 - HTTP method POST is not supported by this URL


type Status report

message HTTP method POST is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL).


Apache Tomcat/6.0.13




This seems to indicate that there's a problem with authentication. I'm given a JSESSIONID and immediately sent to the logout page. I'm also given an HTTP error 405.
The forms in InfoPath use the taskpane combined with some JavaScript trickery to capture the JSESSIONID for an authenticated session so the form is free to communicate with the server and the server thinks this is just a regular Internet Explorer session. I'm thinking that if I can somehow capture this JSESSIONID in OpenOffice, I can use it the same way that InfoPath does. How I'm going to do this, I don't know. It may finally be time to crack into my Macro book and see if I can do some similar HTTP trickery. When I return home and have access to InfoPath, I'll sic tcpmon on it and see what's happening.

Wednesday, August 8, 2007

An OpenOffice.org Annoyance

While working on a form in OpenOffice.org, I noticed something quite annoying.
When you create a form element and bind it to the XML, you can choose what data type you want; date, decimal, string, boolean, etc. On certain data types, such as a decimal, you can define a minimum and maximum range for the data entered:


One would expect you to be able to define a separate range for each different control with type Decimal, right? Wrong. Apparently, if you define a range for ANY control that's type Decimal, it applies to ALL controls of type Decimal. I can't imagine why this is implemented as such because I don't see why you'd want the same range for all different controls. Needless to say, it's problematic.

I'm trying to find the best way to limit the range of values entered for controls such as obs/pulse/value in the OpenMRS forms. In InfoPath, this control (and others like it) have a custom data type, pulse_type_restricted_type, limited to a range of 0-230, inclusive. The entry from the XML schema looks like this:
<xs:simpleType name="pulse_type_restricted_type">
<xs:restriction base="xs:int">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="230"/>
</xs:restriction>
</xs:simpleType>

OpenOffice.org doesn't seem to have this feature. While I can add a custom data type named pulse_type_restricted_type, there doesn't appear to be a way to define a valid range for it. There's an option to add a "Constraint", but I'm not sure how this works. As you can see here, the help files on this are somewhat less than useful:


I'll post some questions to mailing lists and update this post when I've found a solution.