Author Message
DanielStingl
Joined: Nov 20, 2013
Messages: 41
Offline
Hello,

we are consuming a REST-Webservice and have no idea how to get the HTTP status code from the response.

It the server sends 500 internal server error or 400 Bad Request, no exception will be thrown in the orchestration designer.

Well, can anyone explain us how we can get the http response status code from a webservice?

Edit: We are using the REST-Webserivce Connector

Thanks
Daniel
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Are you sure there is no exception thrown? Can you check the trace.log?
DanielStingl
Joined: Nov 20, 2013
Messages: 41
Offline
Hi Wilson,

well I'm not an experience portal expert, but in the trace I don't see any exception.
In the orchestration designer I have wrapped the service call with a try-catch block. The catch block is not hit.

Please see the attached trace (trace_rest-service.log: lines 62 - 70) and the http response.
The output-variable in orchestration designer is filled with the response text "Custom Error Occured" without any information about the status code 500.
The same thing is with status code 400 etc.

Any idea?

thanks
Filename response.txt [Disk] Download
Filename trace_rest-service.log [Disk] Download
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
There seems to be an internal error on the app server (executing the web service). However, the web service does give you a response instead of an exception it should have thrown. I don't know of any way to get the status code from Axis2. I've looked around and can't find any answer either. I think it's the web service's responsibility to throw an error so that the Axis client can render it as such.
DanielStingl
Joined: Nov 20, 2013
Messages: 41
Offline
Hi,

with your answer I tested around with a webservice-mock. The webservice had to return the http status code 500 with a json message like {"message": "..."}.
Then the axis-client detects an error. So the status code 500 alone is not decisive.
With the message, the status code is still hidden and not accessible through the axis client.

Because I can't influence the implementation of the webservice I replaced the axis client with a java servlet and call the service via apache commons httpclient. So I have access to the status code.

Thanks
Daniel
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
That's what I figured how things work. That sounds like your best option.
SimonBrown
Joined: Feb 21, 2014
Messages: 58
Offline
Adding to this post as I have similar issue and concern with REST axis use

We also wanted to try/catch and capture http status code (errors), e.g. 401 and 500

What I found;

If localddtrace=disabled, then the script ignores the try/catch block, and carries on with the Default branch, as nothing happened (the result set is empty)

06/08/2018 10:53:26:694 DEBUG - 3F6E4BD56365B8650D16D0445FFF9AFF:/RestTest : session id:cbyvapceivrmpp01-2018218095326-12 | RestTest:ExecuteWs | Endpoint URL | RESTConfig:endpointUrl : https://DOMAIN/WEBSERVICE/ivraries/v1/rest
06/08/2018 10:53:26:711 DEBUG - 3F6E4BD56365B8650D16D0445FFF9AFF:/RestTest : session id:cbyvapceivrmpp01-2018218095326-12 | RestTest:ExecuteWs | Input | GetClientInfo_Input:mrktCd : CZ
06/08/2018 10:53:26:711 DEBUG - 3F6E4BD56365B8650D16D0445FFF9AFF:/RestTest : session id:cbyvapceivrmpp01-2018218095326-12 | RestTest:ExecuteWs | Input | GetClientInfo_Input:langCd : EN
06/08/2018 10:53:26:711 DEBUG - 3F6E4BD56365B8650D16D0445FFF9AFF:/RestTest : session id:cbyvapceivrmpp01-2018218095326-12 | RestTest:ExecuteWs | Input | GetClientInfo_Input:acctNr : 1234
06/08/2018 10:53:27:475 DEBUG - 3F6E4BD56365B8650D16D0445FFF9AFF:/RestTest : session id:cbyvapceivrmpp01-2018218095326-12 | RestTest:AllGood | Output | GetClientInfo_Output:untitled :


If localddtrace=enabled, then exceptions can be handled, but the log file will be flooded with lot of unnecessary information.

06/08/2018 10:36:26:914 ERROR - F344EC0178D30E1CDB182D072CA62FC5:/RestTest : session id:cbyvapceivrmpp02-2018218093625-16 | RestTest:Error401 | 401 | ddLastException:errorcode : 0
06/08/2018 10:36:26:914 ERROR - F344EC0178D30E1CDB182D072CA62FC5:/RestTest : session id:cbyvapceivrmpp02-2018218093625-16 | RestTest:Error401 | 401 | ddLastException:message : Transport error: 401 Error: Unauthorized
06/08/2018 10:36:26:914 ERROR - F344EC0178D30E1CDB182D072CA62FC5:/RestTest : session id:cbyvapceivrmpp02-2018218093625-16 | RestTest:Error401 | 401 | ddLastException:object : org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
06/08/2018 10:36:26:914 ERROR - F344EC0178D30E1CDB182D072CA62FC5:/RestTest : session id:cbyvapceivrmpp02-2018218093625-16 | RestTest:Error401 | 401 | ddLastException:stacktrace : org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized

In addition, the DDLOG4J.properties file in the project data folder had to have level set to DEBUG manually to capture the error and also allow me to write my own script trace elements.

log4j.logger.Dialog.Designer.TraceWriter.RestTest= debug, TRestTest

Ideally need ability to capture http status in try/catch but without flooding log files with trace info from DD. Require just our own trace statements for none error situations.

Has there been any updates since this post was first created or resource to review?

Thanks


Unless otherwise stated. EP 7.2.0.0.1117 Dev: JVM: 1.8.0_171 OD 7.2.1.0502 tomcat-8.5.23
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Actually this is the first time I've heard of this problem where setting the logging property or not would change the functionality of the try/catch. I am puzzled. Are you catching a special exception? Can you show me the code that is generated in the data node?
SimonBrown
Joined: Feb 21, 2014
Messages: 58
Offline
Hi

I mentioned purpose in previous post.

We also wanted to try/catch and capture http status code (errors), e.g. 401 and 500


Customer web service will return 401 if not authorised and other possible http status errors.
You can see effect of the trace settings in previous reply.

not sure what you mean by showing code that is generated in the data node, sorry. still new to this.


Unless otherwise stated. EP 7.2.0.0.1117 Dev: JVM: 1.8.0_171 OD 7.2.1.0502 tomcat-8.5.23
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
The logs you posted doesn't really tell me whether the catch works or not.
In OD, every node is driven by the Java code generated for the node. The corresponding code is in the WEB-INF/src in the file with the name of node + ".java"
SimonBrown
Joined: Feb 21, 2014
Messages: 58
Offline
I don't see option to upload files or images so hopefully you can see these shares.
The files will auto delete by Sep 14 '18

Java code
Java file

OD Flow
https://azzurricommunications-my.sharepoint.com/:i:/g/personal/simon_brown_azzu_co_uk/EWwbvRnNprBLoEUe8QoH8F4BCBEm6J_gOZnrtM-G4cx9_g?e=SSKX6i

Object code
https://azzurricommunications-my.sharepoint.com/:i:/g/personal/simon_brown_azzu_co_uk/EVkV2qby9ZBBrd2W0FbM7fsBpPo-II3wxLU0MWnTsOQ-Cw?e=9yiIUS


Unless otherwise stated. EP 7.2.0.0.1117 Dev: JVM: 1.8.0_171 OD 7.2.1.0502 tomcat-8.5.23
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
I found the problem. I will post a patch.
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Give this hot patch a try.
Filename ws07.21.05.02.p2.zip [Disk] Download
RajatVerma
Joined: Mar 5, 2014
Messages: 101
Offline
Hi,
I am still not able to figure out how to capture the http response code (4xx, 5xx) while using rest web servcie. In case if web service gives exception, I am able to capture that in exception block but struggling to capture the http resoponse code and body if http response code is not 200.

Any sugegstions? I am using OD rest connector and cant move to custom servlet because of few other dependencies.

Thanks,
Rajat Verma
SimonBrown
Joined: Feb 21, 2014
Messages: 58
Offline
@WilsonYu

Thanks, that patch does fix trace option issue. I assume it will get rolled into future updates naturally?

@RajatVerma
Use try/catch then look at ddLastExcption variable, the message field has fault in it;
ddLastException:object : org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized

Thanks
Simon

Unless otherwise stated. EP 7.2.0.0.1117 Dev: JVM: 1.8.0_171 OD 7.2.1.0502 tomcat-8.5.23
Go to:   
Mobile view