Variables are not retained in pipeline on exception

Hi all,
I have a standard error handling mechanism of [Iam using IS 6.0.1]
-[SEQ]TEST, exit on Success
–[SEQ]TRY, exit on Failure
–[SEQ]CATCH, exit on Done
I have a requirement of open a file stream and decompress it

Herez what iam trying to do

-[SEQ]TEST, exit on Success
–[SEQ]TRY, exit on Failure
–open a file stream(java service)
–decompress it(java service)
–close the file stream(java service)
–[SEQ]CATCH, exit on Done
–getLastError

It works perfectly fine when the compression format of the obtained file is as expected. If the compression format is not as expected,
exception is thrown in decompression.
Now i wanted to close the stream(in CATCH block), if the decompression fails.But the problem is when the control comes to CATCH sequence, stream opened in TRY sequence is lost!!!. I tried putting an object in Input/Output parameter and then assigned it to the stream opened, but even then, the stream is lost, the object variable is null. Worst thing is that the file opened will remain locked and nobody can delete it.
Has anybody faced a similar issue? Please let me know

Guruprasad,

Stream which you have created in the Try sequence is a local variable to that sequence.So, create a global variable outside the first sequence.when you open a stream,map the stream to this variable and this global variable will be available to you in the catch block also.
one more option you have is, in the catch block, you will have a pipeline document under lasterror(lastError/pipeline).In this document,the stream is available.
hope this helps.

ramesh.

Thanks ramesh, it was very helpful
problem is even if I define a global variable, outside the first sequence, the variable is being set to null in the catch block(this might be a problem in decompress java service, it might be setting the variable to null.)
The other option: how do I access the variable in lastError/pipeline document? and map it to the inputstream object in closeinputstream service? during design time you cannot see this variable inside pipleline document. you can see this only during run time. Iam new to webMethods, is there any way to map dynamically generated variable inside a document?
Thanks again for a fast reply…

Guruprasad,

During runtime, copy the lastError document and in the getLastError step ,add this in the pipeline out and map it to the lastError of the service out.now you can get the stream variable and can close it in the catch block.

ramesh.

1 Like

Hi Guruprasad - Regarding your question:
“is there any way to map dynamically generated variable inside a document?”
I think what you are looking for is what wM calls “variable substitution”. In your pipeline out in the CATCH block, create a variable called “myStream” whose input is set to %lastError/pipeline/variableFromTryBlock%. Make sure to set/check in the radio button that says “Variable Substitution”. That will let you code this parameter at design time and access it at runtime.

Hope this helps,
Rajesh

Hello,
You may also want to try the elevated scope variable for the stream. Using some of your provided example:

[invoke] open a file stream(java service)
[SEQ] TEST, exit on Success

  • [SEQ] TRY, exit on Failure
    – [invoke] decompress it(java service)
  • [SEQ] CATCH, exit on Done
    – [invoke] getLastError
    [invoke] close the file stream(java service)

That way, you open and close the stream no matter what happens in the try-done block. Plus it is all easily visible at runtime. Good day.

Yemi Bedu