HTTP invoke ends ok and service fails

My service is executed as an HTTP invoke, and when the service is KO I need to still return OK (200).

How can I do that ?

What do you mean “service is KO”? Then what do you get now when “service is KO”?

If “service is KO” means exception, you may get a status 500, and a message “Service Error”, then you can add a try/catch to make sure no exception is thrown outside the service you invoked, and you can get the 200.

1 Like

Yes 200 only returns when the remote HTTP host does respond fine with no errors and should be accessible from firewall both sides then you would get 200 status.


The service is invoked by another application. The service can fail for 2 reasons :

  • the request is bad, or
  • the content is not ok.

The first case is OK, the IS sends a status 500, so the other application is aware of the error.

In the second case I don’t want to send an error to the other application, I need to manage the error in the IS.

I need to have an error logged in the IS, and to return a status 200 to the other application.

Whatever the service is, wrapped it in a flow service with try/catch sequences, then the service will never throw an exception to other application, and use the pub.flow:getLastError you can manage the error by yourself.


Yes but I would like to have an error present in Services …

If I catch the error, the HTTP call will end ok, but so will the flow and I need the flow to be KO …

One solution would be to separate the HTTP call from the processing with a publish, so the HTTP call can end ok when the processing fails.

But I wondered if there was another way to do it, more directly ?

An asynchronous invoke may be suitable for your situation. The HTTP call service can invoke the back-end service asynchronously through Service.doThreadInvoke, then complete and return OK whatever the back-end is KO or not.

Yes try with Asynchronous mode if you are processing it via TN or have a separate calls for HTTP via doThreadInvoke


Another way to achieve this is by using wM public service pub:flow:setResponseCode, to set required response code (say, 200) when the content is not OK and then continue handling the error in a catch sequence.You can have a additional try/catch block for the content validation.

Yes another idea for response code in a synchronous way:

i worked on this senario once…To do it Syncronusly calling HTTP URL should able to handle response, If not you have do it async away suggested by wang

Yes that’s how it works sync/async modes: