Anonymous
Domino 2.0 Rich Internet Applications with IBM Lotus Notes/Domino
You are here: Today » Creating a server-side proxy using a LotusScript agent
« Building applications for speed
Building a tag cloud from a Notes view with XML and Ajax »

Creating a server-side proxy using a LotusScript agent

To make cross-domain requests with Ajax, e.g. for service oriented applications and mashups, you will need a server-side proxy"". Making one is very easy.

The security

Important: the proxy agent won't work unless the signer has "Run unrestricted methods and operations" rights. This has to be set on the Server document in the NAB, tab 'Security'.

In the agent properties, tab 'Security', you have to set the security level to 2: allow restricted operations. If security settings do not allow the action, you will get an 'Error 201 : Operation is disallowed in this session '.

The LotusScript code

Option Public
Option Declare


Sub Initialize
    On Error Goto catch
    
    Dim session As New NotesSession
    Dim doc As NotesDocument
    Dim sURL As String
    Dim req As Variant
    
    Set doc=session.DocumentContext
    sUrl=GetQueryItem(doc.Query_String_Decoded(0), "url")
    Set req = CreateObject("Msxml2.XMLHTTP")
    Call req.open("GET", sUrl, False)
    Call req.send()
    Print "Response: " & req.responseText    
    Goto finally
    
catch:
    Print "Error " & Err & " : " & Error$
    
finally:
    
End Sub

Function GetQueryItem(query As String, item As String) As String
    
    Dim temp As String, temp1 As String, pos As Integer
    
    temp=query & "&"
    temp1="&" & item & "="
    pos=Instr(temp, temp1)
    If pos>0 Then
        temp=Mid$(temp, pos+Len(temp1))
        GetQueryItem=Left$(temp, Instr(temp, "&")-1)
    Else
        GetQueryItem=""
    End If
    
End Function

The function has to be called with: [/path/db/]proxy?Open&url=[the url]. Don't forget to escape the & into & in order not to break the XHTML validation.

Star rating

0%

Comments

  1. 10/12/2006 23:29:03, Giuseppe Grasso

    am i wrong or this will only work on a windows based server?

To add a comment, log in or register as new user. It's free and safe.