Hi, I have another problem to solve on this subject.
In my project I access IBMi programs as web services like this http://www.ibm.com/support/knowledgecenter/en/SSMQ79_9.5.1/com.ibm.egl.pg.doc/topics/pegl_iseries_program_as_service.html.
Everything works fine!
In the RUI Handler I'm calling the programm as a web service like this:
package it.mr.galileo.handlers;// RUI Widgetimport com.ibm.egl.rui.infobus.InfoBus;import com.ibm.egl.rui.widgets.Box;import com.ibm.egl.rui.widgets.DataGrid;import com.ibm.egl.rui.widgets.DataGridBehaviors;import com.ibm.egl.rui.widgets.DataGridColumn;import com.ibm.egl.rui.widgets.DataGridLib;import com.ibm.egl.rui.widgets.DataGridSelector;import com.ibm.egl.rui.widgets.DataGridSorter;import com.ibm.egl.rui.widgets.Div;import com.ibm.egl.rui.widgets.HTML;import com.ibm.egl.rui.widgets.TextLabel;import egl.ui.rui.Event;import egl.ui.rui.Widget;import dojo.widgets.DojoDialog;import it.mr.galileo.controller.Navigation;import it.mr.galileo.controller.UIError;import it.mr.galileo.lib.Application;import it.mr.galileo.lib.DojoDialogLib;import it.mr.galileo.srv.ILettureSrv;import it.mr.galileo.srv.In_LET;import it.mr.galileo.srv.Out_LET;import it.mr.galileo.srv.Out_LET_dati;//handler Letture type RUIWidget {targetWidget = content, onConstructionFunction = onConstruction , cssFile="css/PortaleRUI.css", @VEWidget{ category = "Custom" }} private rich In_LET; private resp Out_LET; private letture Out_LET_dati[]; private srv ILettureSrv {@BindService}; titolo1 TextLabel{text = "Elenco letture utenza -> ", class = "text14" }; titolo2 TextLabel{text = "", class = "text14", fontWeight = "bold" }; //sorts the rows lexicographically by the elements in the selected column gridSorter DataGridSorter {}; //highlights the row selected gridSelector DataGridSelector { color = "lightgreen" }; grid DataGrid { marginLeft=10, behaviors = [ hideCol, addEditors, centerColumns, DataGridBehaviors.tightCells ], headerBehaviors = [ intesta, hideCol, centerColumns, DataGridBehaviors.grayCells //gridSorter.columnSorter ], columns = [ new DataGridColumn { name = "Matricola", displayName = "Matricola [Correttore]", width = 150, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "QtaContatore", displayName = "Qta Attuale Contatore", width = 100, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "QtaCorrettore", displayName = "Qta Attuale Correttore", width = 100, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "QtaContatoreP", displayName = "Qta Precedente Contatore", width = 120, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "QtaCorrettoreP", displayName = "Qta Precedente Correttore", width = 120, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "QtaConsumoContatore", displayName = "Consumo Contatore", width = 100, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "QtaConsumoCorrettore", displayName = "Consumo Correttore", width = 150, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "DtLetture", displayName = "Data Lettura", width = 80, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "DtIniPer", displayName = "Data Inizio Periodo", width = 80, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "RifDocFatturazione", displayName = "Fattura", width = 130, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "TipoLettura", displayName = "Tipo Lettura", width = 90, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "CoefCorr", displayName = "Coefficiente Correttivo", width = 95, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "StatoLettura", displayName = "Stato Lettura", width = 95, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER}, new DataGridColumn { name = "RifDocAnnRett", displayName = "Documento Annulla/Rettifica",width = 130, headerAlignment = DataGridLib.ALIGN_CENTER, alignment = DataGridLib.ALIGN_CENTER} ], selectionMode = DataGridLib.SINGLE_SELECTION, enableSorting = no, pageSize = 15, showScrollbar = yes, showButtonBar = no, style = "overflow-x: scroll; overflow-y: scroll;", data = (letture as any[]) }; //Main container content Div { children = [ ui], id = "Letture"}; div1 Div {columns = 1, children = [new Box{columns = 3, children = [titolo1,new HTML{width = 10}, titolo2], marginBottom = 40, marginLeft = 10}]}; div3 Div {columns = 1, children = [grid]}; // The UI. ui Div { columns = 1, children = [ div1, div3 ]}; //Alcuni eventi per il render della griglia function addEditors(grid DataGrid in, cell Widget in, row any in, rowNumber int in, column DataGridColumn in) // end function centerColumns(grid DataGrid in, cell Widget in, row any in, rowNumber int in, column DataGridColumn in) cell.style = "text-align: center; word-wrap: break-word; white-space: normal"; end function hideCol(grid DataGrid in, cell Widget in, row any in, rowNumber int in, column DataGridColumn in) // end function intesta(grid DataGrid in, cell Widget in, row any in, rowNumber int in, column DataGridColumn in) cell.height = "30px"; case when (column.name == "QtaContatore") cell.innerHTML = "Quantità Attuale<br>Contatore"; when (column.name == "QtaCorrettore") cell.innerHTML = "Quantità Attuale<br>Correttore"; when (column.name == "QtaContatoreP") cell.innerHTML = "Quantità Precedente<br>Contatore"; when (column.name == "QtaCorrettoreP") cell.innerHTML = "Quantità Precedente<br>Correttore"; when (column.name == "QtaConsumoContatore") cell.innerHTML = "Consumo<br>Contatore"; when (column.name == "QtaConsumoCorrettore") cell.innerHTML = "Consumo<br>Correttore"; when (column.name == "DtLetture") cell.innerHTML = "Data<br>Lettura"; when (column.name == "DtIniPer") cell.innerHTML = "Data<br>Inizio Periodo"; when (column.name == "CoefCorr") cell.innerHTML = "Coefficiente<br>Correttivo"; when (column.name == "RifDocAnnRett") cell.innerHTML = "Documento<br>Annulla/Rettifica"; end end function onConstruction() InfoBus.subscribe(Application.CONST_LETTURE_CALLBACK, lettureCallback); end function start(cliente string) if (cliente != ""); carica(); end end function lettureCallback (event string in, data any in) titolo2.text = Navigation.currentSession.cliente.cCodiceCliente + " - " + Navigation.currentSession.descrCliente; cdcli string = data as string; start(cdcli); end //Carica letture cliente function carica() //Dati input rich.CodiceCliente = Navigation.currentSession.cliente.cCodiceCliente; uri string = Application.CONST_BASE_SRV_URL + "MUPW20LET"; serviceLib.setRestServiceLocation(srv,uri); call srv.letture(rich, resp) returning to srvReturn onException displayException { Timeout = 5000 }; end function displayException(ex AnyException in) closeProgressDialog(); error UIError {origin="Eccezione servizio caricamento letture",exception=ex}; showErrorDialog(error); end function srvReturn(ric In_LET in, res Out_LET in) closeProgressDialog(); servicelib.endStatefulServiceSession(srv, displayException); try // Carica le letture nella grid (eventualmente resta vuota) numElem int = res.datiN; res.dati.resize(numElem); //Dati in GRID grid.data = res.dati as any[]; onException (exc AnyException) closeProgressDialog(); error UIError {origin="Eccezione caricamento griglia letture",exception=exc}; showErrorDialog(error); end end function showMessageDialog(title string in, message string in) DojoDialogLib.showMessage(title, message, buttonClicked); end function showWarningDialog(title string in, message string in) DojoDialogLib.showWarning(title, message, buttonWarningClicked); end function showErrorDialog(error UIError in) s string = error.exception.message; if(exp isa ServiceInvocationException) s += "\nDettaglio1: " +(error.exception as serviceInvocationException).detail1; s += "\nDettaglio2: " +(error.exception as serviceInvocationException).detail2; s += "\nDettaglio3: " +(error.exception as serviceInvocationException).detail3; end DojoDialogLib.showError(error.origin, s, buttonClicked); end function buttonWarningClicked(id String in, e Event in) returns (boolean) Navigation.currentSession = null; Navigation.toLogin(); return (true); end function buttonClicked(id String in, e Event in) returns (boolean) return (true); end private progressDialog DojoDialog; function showProgressDialog() progressDialog = DojoDialogLib.showProgress("Letture cliente", "Caricamento dati in corso...", false, buttonClicked); end private function closeProgressDialog() if (progressDialog != null) progressDialog.hideDialog(); end end end The program is called and does its job responding as it should. The library is set according to the USERID and PASSWORD saved in the protocol in the EGL Deployment Descriptor:
Ok, now I'm trying to set a different USERID and PASSWORD for to change a program resident library on-demand.
New capabilities are introduced in Rational® Business Developer V9.5.1 including one specification to solve my request:
https://www.ibm.com/developerworks/community/blogs/3e2b35ae-d3b1-4008-adee-2b31d4be5c92/entry/Rational_Business_Developer_9_5_1_is_now_available?lang=en
So I added this code in my source for set a specific USERID before to invoke he call to a rogramm:
function carica() //Dati input rich.CodiceCliente = Navigation.currentSession.cliente.cCodiceCliente; uri string = Application.CONST_BASE_SRV_URL + "MUPW20LET"; user string = "RCGMASTER"; pass string = "*********"; serviceLib.setHTTPBasicAuthentication(srv, user, pass); serviceLib.setRestServiceLocation(srv,uri); call srv.letture(rich, resp) returning to srvReturn onException displayException { Timeout = 5000 }; end But the result is the same, the calling the program is ALWAYS whit the USERID=TUGMASTER (that recorded into the protocol in EGL Deployment Descriprtor).
Where's the fault/problem?
@Marcel-D @markevans @Niek_Vandael some ideas??
Matteo@MR