Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Agenda InViewEdit –New event AD203 - Advanced Techniques in LotusScript Recompile All LotusScript –New Menu option LotusScript Remote Debugger –How to use it New Wai-ki Yip Development Manager Merrill Kashiwabara Development team Eng Gary Devendorf Product Manager LotusScript Built-in Functions –Split, Join, StrToken, Replace, ArrayUnique,ShellID –Character sets LS2J (Java Connect) –Calling Java from LotusScript LotusScript Web Services –Writing a Web Service with LotusScript InViewEdit New Used View event for Views to enable editing Items and creating Document in the Event InViewEdit Event Triggers Allows the user to edit a document through its view column entries. Occurs as follows: 1. Query: fires from the View UI –when the user enters an editable view column entry. 2. 3. Validate: –when the user exits an editable view column entry. Save: –after validation of one or more view column entries in an existing document. 4. New entry: –after validation of one or more view column entries in a new document. 1 How to Use InViewEdit Recompile All LotusScript (Menu) Help!!!! Code Demo Recompiles all LotusScript in a database. –Agents, Forms, Script Libraries, Actions, Fields, Views, etc... Each compiled element is "Signed" with the Current Users Signature Alternatives –open up each element, and re-save it to force it to recompile –use the C-API call to compile a document. Why Recompile All? How it Works To Compiles make sure that all LotusScript programs use most current LotusScript library To reflect code changes –LotusScript Source.lss –%INCLUDE To Re-Sign All LotusScript in Database Script Libraries First, Shared Fields, Shared Actions, Forms/Pages, Agents, Views/Folders Compiles in Alphabetical order EXCEPT Script Libraries. –MyAgent –YourAgent Script Libraries –Two pass ordering alphabetically account for dependencies – – 2 Recompile Errors LotusScripts with compile errors are displayed –Not signed –compile not saved –Errors must be fixed by hand Continues compiling through database What does Remote Debugger give you A means to debug LotusScript Agents deployed on a Server Remote Debugger for LotusScript Introduce R5 in Notes/Domino 6 IDE/designer debugging limitations –Agent are debugged on the client only –No way to debug non-Windows Agents –Server Deployed Agents can not be debugged What kind of agents you can debug Agents that you can debug –From the Designer Client –scheduled –Independent of Platform –router agents –Full control of the debug process –Web agents similar to the existing IDE source level debugging single step –runonserver method –run command from the console –step in/over –continue examine set/clear and change the value of the variables breakpoints 3 Remote Debugger - demo Remote Debugger - Agent Configuration Agent must be marked for remote debugging –Property Box Remote Debugger - Client Side Usage Remote Debugger - Client Side Usage (continued) Create An the agent as you would normally –make sure you have designer rights Set the agent to run on the server the remote debugger through the menu Start Agent must be running to attach to it "Agent wait at start time" to slow running agents Use –Slows all agents on the server Use "STOP" statement to create a break point –Remove STOP after debugging –displays all servers all agents running on selected server –displays Once attached, it appears identical to the client IDE Beware of potential performance bottleneck due to transmission time 4 Remote Debugger - STOP statement same Remote Debugger - Architecture as in client IDE server –no op if the debugger is not running difference –check if it is configured for remote debugging –will wait for the specified amount of time –eventually, it will time out and continue Client 1 remote debug add-in Agent LotusScript VM Client 2 server Remote Debugger - Server Configuration Remote Debugger - Server Side Execution Communication Remote Port –IIOP (default to 60000, 60001-ssl) Server Debug Add-In –listens to the port for client communication –creates an proxy for each agent that is running –Enable remote debugger Server document –Start Wait Time (default to 0) –this will also affects the STOP statement –Remote add in will terminate in hrs (default to 24) – –each of this proxy is running as a separate thread –debug commands goes from client to the proxy and to the agent –Agent checks for debug command at its regular intervals –executes the debug command and return values through the proxy to the client. 5 Remote Debugger - Server Side Execution (continued) Advance Feature Server Only one client can be attached to an agent at one time. –The IDE client goes to the regular Notes server to check rights –It is has enough rights, it will ask for the source –It will ask for the connection token to the remote debugger add-in You can take control of an agent someone has already attached to –Very useful when your client crashes –You can still reconnect to the same agent and continue –Able to share a debugging session with someone remotely Remote Debugger - Common Problems Remote Debugger - Security Remote Designer debug add-in is not running (or has been turned off). is not marked "Allow remote debugging" Remotely debugged Agent is running too slow Agent rights to the agent are required –Agent must be marked as remotely debuggable Remote debugger add-in will turn off by itself after some time. Administrator will need to restart it again. Can use the secure port (x509 certificates) instead of the regular IIOP port 6 Remote Debugger - Limitations Limitations –Same as in Client IDE E.g. you cannot debug SUB TERMINATE New Built-in LotusScript Functions Split –Debugging can change the exact conditions on the server Join Just stopping the agent will change the server characteristics. –Slows down the server StrToken – Replace ArrayUnique Split Returns an Array of Strings that are the substrings of the specified String Syntax: Split(expression as String[, delimiter as String[, count as Integer[, compare as Integer]]]) as Variant MyArray=Split("this/is/my/example", "/") MyArray(0)="this" MyArray(1)="is" MyArray(2)="my" MyArray(3)="example Join/Implode Concatenates an Array of Strings delimited by characters or space (" ") Syntax: Join(sourceArray as Variant, [delimiter as String]) as String MyArray(0)="this" MyArray(1)="is" MyArray(2)="my" MyArray(3)="example MySting=Join(MyArray, ".") MyString="this.is.my.example" 7 StrToken Returns a specified "word" from a text string Syntax: StrToken(expression as STRING, delimiter as STRING, wordNumber as LONG, compMethod as INTEGER) as STRING MyString="this.is.my.example" MyWord=StrToken(MyString, ".", 4) ArrayUnique (@Unique) Removes duplicate elements from an Array Syntax: ArrayUnique(sourceArray [,compMethod ]) MyArray(0)="my" MyArray(1)="my" MyArray(2)="my" MyArray(3)="example ArrayUnique(MyArray) MyWord = "example" MyArray(0)="my" MyArray(1)="example" Replace Replaces specific words in a string with new words that you specify Syntax: Replace(sourceArray as Variant, findArray as Variant, replacementArray as Variant[, start as Integer[, count as Integer[, compMethod as Integer]]]) as Variant ShellID Starts another program and returns its task ID Dim task_Id As Variant task_Id = Shellid("calc.exe") Print "Calculator task number = " & taskId 8 LS2J - LotusScript to Java What does LS2J give you Introduce in Notes/Domino 6 a technology used by LotusScript to communicate with Java Treat OLE/COM and Java in a consistent fashion as external objects Bind the object to a reference variable at run time Use Is Don't LS2J - Basics LS2J - How to Use LS2J the extensive Java library or any Java code need to learn the Java syntax to use an existing Java code Don't need to rewrite existing LotusScript application in Java How We have dedicated an entire session on how to use LS2J in detail. We are not going to repeat it here. Instead, we will do a quick review and focus on something new that we have developed since last LotusSphere –how to use Java Library from LotusScript to use LS2J –in the option section –put uselsx "*LS2J" LS2J is implemented as an LSX The "uselsx" statement will cause LS2J to load Contains a collection of LotusScript classes to talk to Java 9 LS2J - Basic Classes Basic LS2J - An Example LS2J classes –JavaSession - represents a connection to an instance of the JVM –JavaClass - represents a Java class of the specified Java package –JavaObject - represents an instance of Java class instantiated –JavaError - represents Java Exceptions and errors. Dim j as new JavaSession Dim c as JavaClass Dim o as JavaObject Set c = j.getClass("com.ibm.lotus.myClass") Set o = c.CreateObject() 'Now "o" references a real Java object LS2J - What you can do with the object Use the dot notation to –get/set its property –invoke its method Support method overloading –get the right method by matching the number of parameters –matching the types –not perfect, dependent on the JNI implementation – For most users, that is all you need to do. Example LS2J - DataType Mapping LotusScript Java BYTE byte BOOLEAN Boolean INTEGER - 16 bit short LONG - 32 bit integer ? long FLOAT float DOUBLE double STRING char, char[], String object ARRAY ARRAY OBJECT OBJECT 10 LS2J - Advance classes LS2J - Where are your Java Classes JavaProperty In - represents a field in the Java class - represents a method in the Java class JavaPropertyCollection/JavaMethodCollection JavaMethod –represents a collection of all properties and methods for the Java class most cases, it is on the hard disk. For example, part of the standard Java library. It comes as default. It will look for it using the ClassPath and the default install location for it. Since it is on disk, it assumes that the user has the right to put the files on. So, it uses the system class loader to load the specified class. LS2J - What are the issues ? LS2J - Script Library Deployment LotusScript –need to install your Java classes on all your user's hard disk yourself Security –assume that the user will take care of this as they must have access to the disk to install the Java code. - USE statement Library - you can put your Java code in a script library Put the two concepts together Script –USE "myJava-ScriptLibrary" Search Order –still disk first –will locate packages and classes in the Script Libraries in the order they are loaded 11 LS2J - Security Script library security rule applies –administrator can sign the script library LS2J - Example of using library Example –at load time, it will merge the rights of all script libraries together –at run time, it will check against the resultant rights - ECL check. LS2J - Limitations limitations –LotusScript can call into Java easily –Cannot pass a LotusScript object into Java for manipulation –Java cannot call into LotusScript directly. The only way is through the AgentRun method. It is due to the threading issues. Web Services Provide programmatic access to remote objects OS and programming language independent! Extends the reach of your applications Exposes your applications to the world Platform, Great 12 Call Remote Methods via SOAP -- (XML) How Web Services Work The Simple Object Access Protocol Consum er SOAP Request SOAP Response consuming (calling) application a method call with parameters Formats the call as XML/SOAP text Sends it via HTTP POST Constructs Web Service Building Block SOAP Protocol -- Request <SOAP-ENV:Envelope xmlns:SOAP-ENV= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:getPrice xmlns:ns1="urn:xmethods-BNPriceCheck" SOAP-ENV:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/"> <isbn xsi:type="xsd:string">0439139597</isbn> </ns1:getPrice> </SOAP-ENV:Body> </SOAP-ENV:Envelope> SOAP Protocol -- Response <SOAP-ENV:Envelope xmlns:SOAP-ENV= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:getPriceResponse xmlns:ns1="urn:xmethods-BNPriceCheck" SOAP-ENV:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="xsd:float">15.57</return> </ns1:getPriceResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> 13 SOAP Protocol -- Response (cont.) Consuming a WS with Java or LS2J The consuming application gets the XML/SOAP response the XML/SOAP response to get the result Result -- Book price is $15.57 Unwraps Notes or Domino Agent Web Service SOAP4J HTTP SOAP Java API SOAPConnect for LotusScript Web Service Description Language (WSDL) Free XML utility file describes the service –www.lotus.com/ldd –Methods –Search on "SOAPConnect" –Parameters LotusScript Library –Data types –URL of the service (end point) Java Agent R5 and Notes/Domino 6 –etc. Where to FIND it 14 Consuming a WS with COM (Windows only) Notes or Domino LotusScript SOAP COM API WSDL MS SOAP Toolkit Weather Service HTTP created in Designer to hold data MS SOAP Toolkit to build and send a request Response came back Extracted price from response Updated Lotus Notes document Called Demonstration Web Service What We Just Saw Form Real Web Service on xmethods.com MS SOAP (think .net)Demo MS SOAP (think .net)Demo –Weather service on xmethods.com –Call Web Service Form Demo 15 What We Just Saw Lotus Domino Application as a WS (Java or COM) LotusScript Accessible Created MS SOAP objects URL for the WSDL file Created proxies for Web Service methods Called the Web Service Put result in Notes document via –Tom Cat Called –WebSphere –Iplanet –.Net Or –100% Domino With LotusScript Providing a Lotus Domino WS 100% Domino -- for Java Providing a Lotus Domino WS Domino SOAP Backend classes NSF Your Progra m Java/.net Container WS Client Domino Backend classes SOAP Web Agent WS Client LotusScri pt Library NSF 16 Providing a Lotus Domino WS 100% Domino - for .NET Domino Backend classes SOAP Web Agent Lotus Domino as a WS Demonstration WS Client LotusScri pt Library NSF .Net Client A Magic 8-Ball "DominoQuote" WSDL Read SOAP/XML POST Text Web Agent Code Set doc = s.DocumentContext '...Get SOAP in... SOAPin= doc.GetItemValue("Request_content")(0) ' ...Tell Domino not to convert text to HTML Print "Content-Type: text/xml" Parse SOAP Document Parse out the Name Space, Method Name, and Argument being passed (use DOM Parser in Release 6) bodyPos= Instr(1,SOAPin,|<SOAP-ENV:Body>|)+15 methodPos= Instr(bodyPos,SOAPin,|:|)+1 methodEnd=Instr(methodPos,SOAPin,| |) MethodName = Mid(SOAPin,methodPos,....) nameSpacePos= Instr(methodEnd,SOAPin,|uri:|)+4 nameSpaceEnd=Instr(nameSpacePos,SOAPin,|"|) NameSpace=Mid(SOAPin,nameSpacePos,(.... .... 17 Running the Domino Web Service Load LotusScript Library based on Name Space Call LotusScript function based on Method Name LSlib = NameSpace Parameter = argValue MyFunction = MethodName Library= |"| & LSlib & |"| Arg= |("| & Parameter & |")| ' load LotusScript Library and call the function CallString = |Use | & Library & | response = | & MyFunction & Arg Execute CallString Build SOAP Response and Send it to Client strTmp = |<?xml version="1.0" encoding="UTF-8"_ standalone="no"?>| &|<SOAP-ENV:Envelope ... ... .... Print strTmp Execute Statment Compiles module. and executes a text expression as a temporary CallString = |Use | & Library & | response = | & MyFunction & Arg Execute CallString What Did We See? Client application sent request -XML/SOAP processed request Server –Established a Notes session –Picked a random number –Accessed a document in Domino DB Print XML/SOAP response to client Client displayed result 18 WSDL Tools Related Presentations IBM AD402: WebSphere Studio Application Developer Web Services Toolkit MS Visual Studio .NET etc. Adding a Web Services Interface to Your Lotus Domino Applications. Tuesday, 1/28, 4:30 AD205: Lotus Notes/Domino 6 Agents: Practical Guide to New Features. Monday, 1/27, 3:15 AD207: Lotus Domino 6 Objects By Example. Tuesday, 1/28, 12:15 AD302: Lotus Domino Designer Advanced Topics. Tuesday, 1/28, 4:30, or Wednesday, 1/29, 2:30 AD201: @Formula Language Tips and Techniques. Tuesday, 1/28, 4:30 AD105: "Must Have" Additions to Your Lotus Notes 6 Client Applications. Wednesday, 1/29, 10:30 IBM Tool Questions & Resources WWW.Lotus.com/LDD IBM Redbook Questions? 19