on 11-13-2006 12:15 PM
Hi all,
we have the following problem in graphical XI mapping.
Trying to retrieve the run-time value of a global parameter, we cannot access the value itself (e.g. test using "display queue" menu).
We use 2 simple user-defined functions (getIdoc and corresponding setIdoc).
The source code for our custom get/set methods is:
public String getIdoc(Container container){
// This is a CUSTOM global parameter set <- cannot get the value itself
//String codMsgExport = (String) container.getGlobalContainer().getParameter("idoc");
//return codMsgExport.toString();
GlobalContainer globalContainer;
java.util.Map map;
globalContainer = container.getGlobalContainer();
map = globalContainer.getParameters();
// This is a STANDARD global parameter set <- cannot get the value itself, as well
String headerField = (String) map.get(StreamTransformationConstants.INTERFACE_NAMESPACE);
return headerField;
}
public String setIdoc(String codMsgExport,Container container){
container.setParameter("idoc", codMsgExport.toString());
String retValue = (String) container.getGlobalContainer().getParameter("idoc");
return retValue.toString();
}
=> anyway, get method returns only blank values (testing by "display queue" with some custom values...)
It seems as if the parameter is seen, as pointing to a not existing variable - e.g. getParameter("idoczz") - XI runtime returns a NullPointerException.
Some XI server details:
Runtime Environment
Java version: 1.4.2_06
Java vendor: Sun Microsystems Inc.
Version
Service pack: 14
Release: 30_REL
Thanks all!
Gianluca Tacchella
Hi,
Are you testing the UDF using the TEST tab of your message mapping? if yes, in this case, you would need to add the values for fields (Interface Namespace ) in your TEST under the tab PARAMETERS .
have you done this?
Regards,
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sudharshan and Bhavesh,
I forgot to put a value under the tab PARAMETERS (this is the reason for the blank value, thanks:)).
Anyway, modifying (run-time by the set function) the standard runtime constant => leads to a get function with a single value returned (out) for "display queue", despite of test valorization: the initial value set under tab PARAMETERS.
Instead of using the runtime (standard) constant, using my (custom) global variable => leads to NullPointerException ("display queue" for get function) EVEN IF I initialize the variable (e.g. initIdoc() function called once at top-level target message).
********
under JAVA_SECTIONS_TOOLTIP button:
Global Variables
String idoc;
Initialization Section
idoc = "";
Clean-Up Section
idoc = "";
********
public String initIdoc(Container container){
GlobalContainer globalContainer;
globalContainer = container.getGlobalContainer();
// this is the only way NOT to get a NullPointerException
if ( globalContainer.getParameter("idoc") == null )
globalContainer.setParameter("idoc", "a");
return globalContainer.getParameter("idoc").toString();
}
initIdoc:
out (*)
[a]
(*) despite of initialization under JAVA_SECTIONS_TOOLTIP button
********
public void getIdoc(ResultList result,Container container){
//String codMsgExport = (String) container.getGlobalContainer().getParameter("idoc");
//return codMsgExport.toString();
GlobalContainer globalContainer;
java.util.Map map;
globalContainer = container.getGlobalContainer();
map = globalContainer.getParameters();
//String headerField = (String) map.get(StreamTransformationConstants.INTERFACE_NAMESPACE);
// this returns null (out stream)
//String headerField = (String) map.get("idoc");
//if ( globalContainer.getParameter("idoc") == null )
//globalContainer.setParameter("idoc", "");
// this returns NullPointerException
String headerField = globalContainer.getParameter("idoc").toString();
//result.addValue(headerField);
// this returns NullPointerException
//return headerField.toString();
//return globalContainer.getParameter("idoc").toString();
result.addValue(globalContainer.getParameter("idoc").toString());
}
=> leads to NullPointerException
********
public String setIdoc(String codMsgExport,Container container){
GlobalContainer globalContainer;
globalContainer = container.getGlobalContainer();
java.util.Map map;
map = globalContainer.getParameters();
//globalContainer.setParameter(StreamTransformationConstants.INTERFACE_NAMESPACE, codMsgExport.toString());
//container.setParameter("idoc", codMsgExport.toString());
//String retValue = (String) map.put(StreamTransformationConstants.INTERFACE_NAMESPACE, codMsgExport.toString());
// this returns a NullpointerException
//String retValue = (String) map.put("idoc", codMsgExport.toString());
globalContainer.setParameter("idoc", codMsgExport.toString());
//return "True"; // pointer for debug
//return retValue.toString(); // pointer for debug
return globalContainer.getParameter("idoc").toString();
}
setidoc:
in0 out (*)
[1] [1]
[2] [2]
(*) as if this "idoc" parameter is not the globally managed (JAVA_SECTIONS_TOOLTIP button), but one which lives inside the function and not outside for the get function..
********
Regards,
Gianluca
The parameters in global container and the attributes in the java sections are not equal.
You can declare attributes and use them directly without global container:
public String setIdoc(String codMsgExport,Container container){
idoc = codMsgExport;
return(codMsgExport);
}
public void getIdoc(ResultList result,Container container){
result.addValue(idoc);
}
Or you work with global container like this:
public String setIdoc(String codMsgExport,Container container){
container.getGlobalContainer().setParameter("idoc", codMsgExport);
return(codMsgExport);
}
public void getIdoc(ResultList result,Container container){
result.addValue((String)container.getGlobalContainer().getParameter("idoc"));
}
Make sure, that the functions set function is connected in the target at higher level as the get function.
Regards
Stefan
Hi Stefan,
Can I use Global Container to store/setParameter the value of a field1 from response of a synchronous interface and use/retrieve the field1 from Global Container getParameter in the next run of a interface.
1. Run1: Request --> Response (store field1 using global container)
2. Run2: Request (get field1 stored in Run1) --> Response
Let me know if it is possible as I tried and it was failing or any other approach is possible to achieve the above scenario.
Regards,
Nitin Patil
Hi Gianluca,
Make sure that the set parameter part is called first during execution before the get parameter in UDF. Else u might get null pointer exception.
Regards,
Sudharshan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
74 | |
10 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.