GetLastError doesn%b4t work in this case

Hi folks,

I wrote a service that tries to send a document (XML) via HTTP/Post and I need to consider a failure any header/status response different from 200.

To do this I built a flow like this:

SEQUENCE (SUCCESS)
| SEQUENCE(FAILURE)
| | REPEAT (on FAILURE - count 5)
| | | HTTP
| | | BRANCH on /header/status
| | | | 200: EXIT $parent signal SUCCESS
| | | | $default: EXIT $parent signal FAILURE
| SEQUENCE(DONE - because it might find an error too)
| | getLastError
| | BRANCH on /lastError
| | | $null:writeToFile
| | | $default:debugLog

The problem is EXIT step won’t throw an exception when you’re exiting and signaling FAILURE.
Where did I go wrong in this flow or how can I treat this issue?

TIA,
Maldonado

Renato,

I have taken small example on this, it is working fine for me. Exit step is throwing an exception. But you can't see any error in pipeline, then the flow excuting $null branch. If you would like to see exactly an error message, instead of using exit step use service exception with an error message, then in getLastError step you see that error in pipeline.

Did you used the sequence to specify (if-else condition) for 200 and default as:

BRANCH on /header/status
|200:SEQUENCE
|||EXIT $parent signal SUCCESS
|$default:sequence
|||EXIT $parent signal FAILURE

Renato,
You may find this thread informative/helpful: http://www.wmusers.com/wmusers/messages/117/18520.shtml. I also recall reading something about the Exit step not throwing an exception in a particular situation (I believe it may have involved the REPEAT step), but I can’t find it again yet. If I track that down I’ll pass on a pointer. There are some other interesting threads here as well if you feel like reading. Just search the forums for “Exit Step”.

The thread that Michael linked to is about a slightly different issue, but the same underlying cause. It’s a common mistake to think that getLastError can get the error message that you specify in an Exit step. It most certainly does not work that way. The getLastError step only returns the last Java exception message - either from the failure of another service or from a custom Java step that throws a ServiceException.

Be careful with anything that throws an exception in a REPEAT step. In my experience, repeat steps do a very poor job of passing exception messages that are thrown inside them.

Guys,

Thanks a lot for your responses.
Michael,
I saw this thread before start this thread, but how I can´t always throw an exception I should not use that tip.
Skip,
You’re right … I set an error message in the EXIT step, but getLastError didn’t get it.

Actually I change the logic of my flow and now it works.
Basically, I gave a label ‘start’ to 1st SEQUENCE, change the REPEAT on-FAILURE to REPEAT on-SUCCESS and into the BRANCH on /header/staus I invoke a EXIT ‘start’. After that I moved the writeToFile right before the REPEAT.

Many, many thanks guys.
Maldonado