MWS Functions. Perceptive Software Document Composition Studio
Mainos
Mainos
MWS Functions
About MLMwsClient
The MonaLisa object MLMwsClient enables you to use MWS functions. The object provides all functions necessary for communication with the MWSProcessService, general helper function, and various properties required. For a description of the structure and meaning of the various options XMLs, XML results, and result codes, refer to the
Perceptive Document Composition Web Services Developer’s
Guide.
To load the object, use the MonaLisa function GetObject .
Example
GetObject("MwsClient","MLMwsClient")
Functions of the Class MLMwsClient
ClearCache
Clears the cache of the RepositoryRuntimeService.
ClearCache
SYNTAX ClearCache()
RETURN
EXAMPLE
0 = Successful
<>0 = Unsuccessful
ClearCache()
Doc_GetFile_Mime
Returns a file that manages the business object.
Doc_GetFile_Mime
SYNTAX Doc_GetFile_Mime(processId, fileName)
ARGUMENTS processId ID of the process whose business object you want to manage. fileName File name. doc Base64 coded string, representing the content of the file. xmlResult Empty when OK.
RETURN 0 = Successful
<>0 = Unsuccessful
Doc_SetFile_Mime
Writes a file that manages the business object.
Doc_SetFile_Mime
SYNTAX Doc_SetFile_Mime(processId, fileName, doc)
ARGUMENTS processId ID of the process whose business object you want to manage. fileName File name.
236
RETURN doc Base64 coded string that represents the content of the file. xmlResult Empty when OK.
0 = Successful
<>0 = Unsuccessful
GetList
Returns a list of all currently existing processes.
GetList
SYNTAX
ARGUMENTS
RETURN
GetList(startAt, max, options) startAt max
Start index.
Maximum number of processes to return. options Use this parameter to specify which processes you want to include in the retrieved process list. xmlResult An MwsProcessList XML when successful, otherwise an MwsError.
0 = Successful.
<> = Not successful.
Obj_GetStructure
Returns the structure of the referenced object.
Obj_GetStructure
SYNTAX Obj_GetStructure(processId, rootRef, maxLevel)
ARGUMENTS processId ID of the process the object references. rootRef Object reference within the process. maxLevel -1 = All
0 = Just the object.
>0 = The structure including all child elements at the n-th level. xmlResult Object XML depending on the component.
RETURN 0 = Successful
<>0 = Not successful.
Obj_SetStructure
Sets the structure of the business object.
Obj_SetStructure
SYNTAX Obj_SetStructure(processId, content, rootRef, maxLevel)
ARGUMENTS processId ID of the process the object references. content rootRef
The business object information to set.
Object reference whose structure returns.
237
RETURN maxLevel Determines how many levels return.
-1 = All
0 = Just the object.
>0 = The structure including all child elements at the n-th level. xmlResult Object structure of the business object, if OK.
0 = Successful
<>0 = Not successful.
Obj_Toggle
Toggles the status of an object.
Obj_Toggle
SYNTAX
ARGUMENTS
RETURN
Obj_Toggle(processId, objRef, rootRef, maxLevel) processId ID of the process the object references. content rootRef
Reference of the object to toggle.
Object reference whose structure returns. maxLevel Determines how many levels return.
-1 = All
0 = Just the object.
>0 = The structure including all child elements at the n-th level. xmlResult Object structure of the business object, if OK.
0 = Successful
<>0 = Not successful.
Ping
Returns the string "MWS Process Service".
Ping
SYNTAX Ping()
RETURN "MWS Process Service"
Process_Close
Closes a process with the passed in status.
Process_Close
SYNTAX Process_Close(processId, status, options)
ARGUMENTS processId Process ID. status options
Free text status definition.
Close options XML with title and description. xmlResult Empty when OK.
238
RETURN 0 = Successful.
<> 0 = Not successful.
Process_Create
Creates a new MWS process.
Process_Create
SYNTAX Process_Create(processId, mSystem, mType, mTitle, objectIndex, objectName, objectType, objectData, options)
ARGUMENTS processId mSystem
If the process ID is not passed in, a new one is created.
System OID of the system the object to load resides in. mType mTitle
Free text to define the process type.
Free text to define a title for the process. objectIndex Index of the object to load. If this parameter is defined, the objectName parameter is ignored. objectName Name of the loaded object. This parameter is only taken into account if objectindex is not specified. objectType objectData
Type of object to load. Currently only "P" for bundles is possible.
Optional XML data for a bundle. The data is assigned to the first passive selection in the OnNewStart script. options xmlResult
Options XML for the MWS process.
If the process is created, either the bundle structure or process information returns.
The bundle structure returns if a start command passes to the options.
RETURN 0 = Successful.
<> 0 = Not successful.
Process_Delete
Deletes an open process and frees its server resources.
Process_Delete
SYNTAX Process_Delete(processId)
ARGUMENTS processId ID of the process to delete. xmlResult Empty when OK, otherwise MwsError.
RETURN 0 = Successful.
<> 0 = Not successful.
Process_Forward
Forwards a process.
Process_Forward
239
SYNTAX
ARGUMENTS
RETURN
Process_Forward(processID, destUser, destUsergroup, options) processID destUser
Process ID.
Name of the target user the process forwards to. destUsergroup Name of the target group the process forwards to. options Close options XML with title and description. xmlResult Empty when OK.
0 = Successful.
<> 0 = Not successful.
Process_GetInfo
Returns information about the process.
Process_GetInfo
SYNTAX Process_GetInfo(processId, infoType, options)
ARGUMENTS processId ID of the process for which the information returns. infoType Comma separated string containing the information to retrieve.
This information is the predefined types PROCESSINFO and POOLVARS. The
MWS process is dependent and is loaded and evaluated by the OnGetInfo script.
RETURN options Currently not supported. xmlResult ProcessInfo XML when OK.
0 = Successful.
<> 0 = Not successful.
Process_GetLastError
Returns the last error of a process.
Process_GetInfo
SYNTAX Process_GetLastError(processID)
ARGUMENTS processId ID of the process for which the last error retrieves. xmlResult Last error XML when successful.
RETURN 0 = Successful.
<> 0 = Not successful.
Process_Open
Resumes processing of a process and sets the user name to that of the current user.
Process_Open
SYNTAX Process_Open(processId, options)
ARGUMENTS processId ID of the process to open.
240
RETURN xmlResult Currently not supported.
0 = Successful.
<> 0 = Not successful.
Process_SetData
Sets XML data for the business object.
Process_SetData
SYNTAX Process_SetData(processId, dataType, data)
ARGUMENTS processId ID of the process. dataType Name to assign to the data. Currently refers to the name of the data reference. data The XML data to set. xmlResult Empty when OK.
RETURN 0 = Successful.
<> 0 = Not successful.
Process_Start
Starts a process action.
Process_Start
SYNTAX Process_Start(processId, command, options)
ARGUMENTS processId Process ID of the process where the action starts. command Contains the command to pass in. The names of the commands derive from the
InvokeActivities script of the MWS process. options You can use this parameter to set various options of the process, to set process activities, and to pass in variables. xmlResult The structure of the bundle when successful.
RETURN 0 = Successful.
<> 0 = Not successful.
Srv_GetInfo
Returns information about the MWS server.
Srv_GetInfo
SYNTAX
ARGUMENTS
Srv_GetInfo(options) options Currently not used xmlResult MWS server info XML if OK, otherwise MWSError
RETURN
EXAMPLE
0 = OK
<> 0 = Error
GetObject("MwsClient","MLMwsClient")
241
…
… options = "" resultCode = MwsClient.Srv_GetInfo(options) xmlResult = MwsClient.LastXmlResult
Protocol(resultCode, 8)
Protocol(xmlResult, 8)
Class Helper Functions
LoadBase64StringFromBinFile
Loads the specified file and converts the contents in a Base64 string.
LoadBase64StringFromBinFile
SYNTAX LoadBase64StringFromBinFile(binFileName)
ARGUMENT
S binFileName File name.
RETURN
EXAMPLE
Base64 coded string of the file. If no file exists, an empty string returns. newDocString =
MwsClient.LoadBase64StringFromBinFile("c:\temp\MyDoc_changed.docx"
)
SaveBase64StringToBinFile
Writes a Base64 string converted to a byte array to a binary file.
SaveBase64StringToBinFile
SYNTAX SaveBase64StringToBinFile(base64Content, binFileName)
ARGUMENTS base64Content Base64Content binFileName File name
RETURN
EXAMPLE
TRUE = File written
FALSE = File not written if (myDocString <> "")
ok = MwsClient.SaveBase64StringToBinFile(myDocString,
"c:\temp\MyDoc_org.docx") end-if
Properties of the class MLMwsClient
Property Description
LastBase64DocumentString Allows you to read the last Base64 string retrieved.
Read-only property.
The MWSService function Doc_GetFile_Mime returns the Base64 coded string of the specified document in addition to an integer result code and the XML result string.
242
LastProcessId
LastXmlResult
MwsUrl
Example
myXmlResult = "" resCode = MwsClient.Doc_GetFile_Mime(myProcessId, filename) myDocString = MwsClient.LastBase64DocumentString myXmlResult = MwsClient.LastXmlResult
Allows you to read the last process ID retrieved.
Read-only property.
The MWSService function Process_Create enables you to define a process ID or, if the corresponding parameter is passed as an empty string, enables you to automatically generate a process ID.
This is irrespective of whether the process ID was predefined or created automatically.
The property is set with the corresponding process ID when the Process_Create function call was successful.
Example
myXmlResult = "" myProcessId = "" options = "" resCode = MwsClient.Process_Create(myProcessId, "dm1",
"MyType", "MyTitle", "", "MyBundleName",
"P", "", options) myProcessId = MwsClient.LastProcessId myXmlResult = MwsClient.LastXmlResult
Allows you to read the last XmlResult string retrieved.
Read-only property.
Most MWSService functions return both an integer result code and an XmlResult as string.
Example
myXmlResult = "" resCode = MwsClient.Process_Open(myProcessId, "") myXmlResult = MwsClient.LastXmlResult
Allows you to define the URL of the MWS server.
The property must be set with the address of the MWS service before the first call of the MWS service is made.
Internally, when the property is being set, a previously opened service channel is closed so that the following call to the MWS service can create a new service channel.
If this property is not defined, the first call to the MWS service tries to read the required URL for the MWS service from the key appSettings (key="mws").
An exception is thrown if no corresponding setting can be found here either.
Example
MwsClient.MwsUrl = "http://localhost:8011/mws/mwsprocess"
Sample Script MLMwsClient
;********************* MLMwsClient ****************************************
;
GetObject("MwsClient","MLMwsClient")
;
MwsClient.MwsUrl = "http://localhost:8011/mws/mwsprocess"
; dummy = MwsClient.Ping()
243
Protocol(dummy, 8)
;
; On setting the URL, a previously created ServiceChannel is closed
;MwsClient.MwsUrl = "http://localhost:8011/mws/mwsprocess"
;dummy = MwsClient.Ping()
;Protocol(dummy, 8)
;MwsClient.MwsUrl = "http://localhost:8011/mws/mwsprocess"
;dummy = MwsClient.Ping()
;Protocol(dummy, 8)
; myXmlResult = "" myProcessId = "" options = "<mws><mwsaction name=""DATASELECTION"" configured = ""1""
><selparams><selparam name=""Partnernumber"" >0815</selparam><selparam name=""test""></selparam></selparams></mwsaction></mws>" res = MwsClient.Process_Create(myProcessId, "dm1", "MyType", "MyTitle", "",
"Application2", "P", "", options) myProcessId = MwsClient.LastProcessId myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
; if (res = 0)
myXmlResult = ""
res = MwsClient.Process_Start(myProcessId, "CREATE_DOCUMENTS", "")
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8) end-if
; if (myXmlResult <> "")
filename = ""
GetObject("xml", "MLXmlDocument")
xml.LoadXml(myXmlResult)
filename = xml.GetAttribute("/mws/process/object/object[1]", "filename")
FreeObject("xml") end-if
; if (filename <> "")
res = MwsClient.Doc_GetFile_Mime(myProcessId, filename)
myDocString = MwsClient.LastBase64DocumentString
Protocol(myDocString, 8)
Protocol(res, 8)
if (myDocString <> "")
ok = MwsClient.SaveBase64StringToBinFile(myDocString,
"c:\temp\MyDoc_org.docx")
Protocol(ok, 8)
end-if end-if
244
;
; now alter document, upload it and then download it again for manual check if (filename <> "")
myNewDocString =
MwsClient.LoadBase64StringFromBinFile("c:\temp\MyDoc_changed.docx")
Protocol(myNewDocString, 8)
if (myNewDocString <> "")
res = MwsClient.Doc_SetFile_Mime(myProcessId, filename, myNewDocString)
Protocol(res, 8)
if (res = 0)
res = MwsClient.Doc_GetFile_Mime(myProcessId, filename)
myDocString = MwsClient.LastBase64DocumentString
Protocol(myDocString, 8)
Protocol(res, 8)
if (myDocString <> "")
ok = MwsClient.SaveBase64StringToBinFile(myDocString,
"c:\temp\MyDoc_downChanged.docx")
Protocol(ok, 8)
end-if
end-if
end-if end-if
;
; upload any file and download it again filename= "c:\temp\MMDMO_33.B.migrate.xml" myFileString = MwsClient.LoadBase64StringFromBinFile(filename)
Protocol(myFileString, 8) res = MwsClient.Doc_SetFile_Mime(myProcessId, filename, myFileString)
Protocol(res, 8) if (res = 0)
res = MwsClient.Doc_GetFile_Mime(myProcessId, filename)
myFileString = MwsClient.LastBase64DocumentString
Protocol(myFileString, 8)
Protocol(res, 8)
if (myFileString <> "")
ok = MwsClient.SaveBase64StringToBinFile(myFileString,
"c:\temp\MMDMO_DOWNLOAD_33.B.migrate.xml")
Protocol(ok, 8)
end-if end-if
;
;all remaining methods possible if (myProcessId <> "" )
myXmlResult = ""
res = MwsClient.Obj_GetStructure(myProcessId, "", 1)
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
245
myXmlResult = ""
res = MwsClient.Obj_Toggle(myProcessId, "3C331B86-8552-4AD6-A242-
29106BFBCA21", "", 1)
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
myXmlResult = ""
res = MwsClient.Process_SetData(myProcessId,
"My_nonExisting_BundleDataId", "<data>MyDataString</data>")
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
myXmlResult = ""
res = MwsClient.Process_GetLastError(myProcessId)
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
myXmlResult = ""
res = MwsClient.ClearCache()
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
myXmlResult = ""
res = MwsClient.Process_GetInfo(myProcessId, "PROCESSINFO", "")
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
content = "<mws type=""OBJECT"" version=""1""><process><object action=""includedoc"" name=""TestDocument"" target_reference="""" position=""after"" /></process></mws>"
myXmlResult = ""
res = MwsClient.Obj_SetStructure(myProcessId, content, "", 1)
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
myXmlResult = ""
res = MwsClient.Process_GetInfo(myProcessId, "PROCESSINFO", "")
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
options = "<mws version=""2""><title>Forwarded to
Mike</title><description>Description of the task</description></mws>"
246
myXmlResult = ""
res = MwsClient.Process_Forward(myProcessId, "Mike", "", options)
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
options = "<mws><processlist><item name=""listuser"" include=""Mike""
/><item name=""shortprocdesc"" include=""30"" /></processlist></mws>"
myXmlResult = ""
res = MwsClient.Process_GetList(0, 100, options)
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
;IntegerDate = date.DateStringToInt64("ddMMyyyyHHmmss", "21012010174853")
;DateStr = date.Int64ToDateString("MM-dd-yyyy HH:mm:ss", IntegerDate)
;
options = "<mws><processlist><item name=""listuser"" include=""Mike""
/><item name=""shortprocdesc"" include=""30"" /><item name=""forwarded"" include=""1"" /><item name=""nonforwarded"" include=""0""
/></processlist></mws>"
myXmlResult = ""
res = MwsClient.Process_GetList(0, 100, options)
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
myXmlResult = ""
res = MwsClient.Process_Open(myProcessId, "")
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
myXmlResult = ""
res = MwsClient.Process_GetTransDocsList(myProcessId, "")
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
myXmlResult = ""
res = MwsClient.Process_Close(myProcessId, 0, "")
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
myXmlResult = ""
res = MwsClient.Process_Delete(myProcessId)
myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
247
Protocol(res, 8)
; end-if
; myXmlResult = "" res = MwsClient.Process_GetList(0, 100, "") myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
FreeObject("MwsClient")]]></scriptcode>
;
Sample Script: Create a Process
GetObject("MwsClient","MLMwsClient")
MwsClient.MwsUrl = "http://localhost:8011/mws/mwsprocess" result = MwsClient.Ping()
Protocol(result, 8)
; myXmlResult = "" myProcessId = "" options = "" res = MwsClient.Process_Create(myProcessId, "MySystemOId", "MyType",
"MyTitle", "", "MyBundleName", "P", "", options) myProcessId = MwsClient.LastProcessId myXmlResult = MwsClient.LastXmlResult
Protocol(result, 8)
Protocol(res, 8)
;
FreeObject("MwsClient")
248
Lataa
Mainos