Lapas

Thursday 3 December 2009

XPAGES and Domino Web Services

Primary question how to call domino web services from XPAGES with authorization. There is method to do it:
1. Use Apache AXIS API to access and work with web services (API ref: http://ws.apache.org/axis/java/apiDocs/index.html).
2. Create service using
var service:org.apache.axis.client.Service = new org.apache.axis.client.Service();
3. Create call
var call:org.apache.axis.client.Call = service.createCall();
4. For authorization purposes if domino user is logged in:
call.setMaintainSession(true); - !Important
call.setProperty("Cookie","SessionID="+cookie.get("SessionID").getValue()+",DomAuthSessId="+cookie.get("DomAuthSessId").getValue())
5. Then simply call then web service and get your result:
var xmlType = new javax.xml.rpc.encoding.XMLType();
call.setTargetEndpointAddress({webServiceAddress});
call.setOperationName( {operationName} );
call.addParameter("INPUT1", xmlType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.addParameter("INPUT2", xmlType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.setReturnType(xmlType.XSD_STRING);
var a = new java.lang.Object[2];
a[0] = "param1";
a[1] = "param2";
var rating = call.invoke(a);

Authorization for SSO based login:
If your server is using basic http authorization, then previous demonstrated code should be modified to support basic http authorization. So we need to copy information from http header and pass it in web service request.
1. use headerValues global variable
2. check if headerValues.AUTHORIZATION or headerValues.containsKey("AUTHORIZATION")
3. set it in call property like call.setProperty("AUTHORIZATION",headerValues.AUTHORIZATION.nextElement()) or call.setProperty("AUTHORIZATION",headerValues.get("AUTHORIZATION").nextElement()).

Why is to use nextElement()? headerValues.get("AUTHORIZATION") returns single value enumeration, so to get string value we need to get element from list.

Problem detected when using apache axis in xpages internal requests (made using ssj - Server Side Javascript) is that sometimes domino server java class loader stop working correcly loading apache axis class org.apache.axis.client.Service() - required restart to work correctly.

Tuesday 17 November 2009

Lotus Notes Outline tricks

Here are some tricks switching selected outline entry in embedded outlines:
1. We need for outline entries to define aliases, that could be used for referencing
2. For embedded outline should be defined name attribute (ex. "MyOutline").
3. To select required outline entry programmaticly it is required to set field "$MyOutline" ($ should be used as prefix for fields - full syntax "$"+OurDefinedOutlineName) value in opened document (to which embedded outline belongs) to outlineentry alias name (ex. "myDocs") and then doc should be refreshed, to apply entry selection.

P.S. @now there are problems to select outline entry just after form load, only using timer.

Friday 16 October 2009

How to add computed custom control to XPAGE at runtime

Very simple technique:
You need to know, that "include page" control could include not only page elements, but also custom control elements, but you should write then by Your hands.
So @1st create a repeater on page.
Then add include page control in repeater.
As repeater values set array of controls to add ex. ["ccontrol1.xsp", "ccontrol2.xsp",...]
use those values to compute page.