on 02-03-2020 2:00 PM
Hello experts,
${header.CamelHttpResponseCode} : Is this the correct header parameter to get the HTTP status code when an exception occurs?
I am unable to access this value in exception sub-process block in the iFlow.
Regards
Hi Keshav,
in case of an exception (subprocess) it should also be possible to read the status code from the exception. In Groovy you would write something like this:
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
def map = message.getProperties();
def ex = map.get("CamelExceptionCaught");
if (ex!=null) {
message.setHeader("status_code", ex.getStatusCode());
}
return message;
}
Then you could access the status code after the script step via the "status_code" header for routing purposes, etc.
Best regards,
Raffael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Raffael. Yes, I can get the status code in the script. Surprised why the same cannot be accessed using the simple expression in the content modifier [by creating a new header/exchange property/even while setting the body].
Also, what other methods can we access from the exception object [
def ex = map.get("CamelExceptionCaught");]? In my case I am getting a
org.apache.cxf.binding.soap.SoapFault exception.
Hi Keshav,
there are also methods like "getStatusText" and "getResponseBody" in the exception object. Check the samples over here: https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/a443efe1d5d2403fb95ee9def1a...
In addition, maybe you don't need a script to access the status text, but can set it directly to a property by using Apache Simple Expression. It could work like the following (but I haven't tested it - so no proof that it works):
${property.CamelExceptionCaught.getStatusCode()}
Thanks for your reply Raffael. Unfortunately, not all methods [get*] listed for the SoapFault in
https://cxf.apache.org/javadoc/latest/org/apache/cxf/binding/soap/SoapFault.html will return details of the fault. I am, however able to get the status code and a message [does not detail the cause of exception], to use in the error log for my response message.
I did notice that in message monitoring, 'Open Text View' in the Logs [even in case of log level Info] has details of the exception, like the status text etc. I believe to get these log details, we will have to use the ODATA API to query the message processing log (?)User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
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.