Author |
Message
|
whiting |
Posted: Wed Jun 01, 2016 12:49 pm Post subject: JSON error response from HTTPInput timeout |
|
|
Acolyte
Joined: 26 Mar 2002 Posts: 64 Location: Greenville, SC
|
I'm working with IIB 9.0.0.4
I am creating a REST to MQ mediation flow. In the event of an error or timeout, I want to return a JSON formatted response to the calling application.
If I get an error indication from the back-end MQ application there is no problem creating an JSON error reply and sending that through an MQReply node. However, if there is no response from the MQ application, then the response returned to the client is an HTML or SOAP error.
Is there a way to configure the HTTPInput node so that it will return a JSON string?
I've tried catching the timeoput at the HTTP Timeout terminal as well as the Fail or Catch terminals and regardeless of what I put in the OutputBody, the client gets HTML or SOAP. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Jun 01, 2016 1:41 pm Post subject: Re: JSON error response from HTTPInput timeout |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
whiting wrote: |
I'm working with IIB 9.0.0.4
I am creating a REST to MQ mediation flow. In the event of an error or timeout, I want to return a JSON formatted response to the calling application.
If I get an error indication from the back-end MQ application there is no problem creating an JSON error reply and sending that through an MQReply node. However, if there is no response from the MQ application, then the response returned to the client is an HTML or SOAP error.
Is there a way to configure the HTTPInput node so that it will return a JSON string?
I've tried catching the timeoput at the HTTP Timeout terminal as well as the Fail or Catch terminals and regardeless of what I put in the OutputBody, the client gets HTML or SOAP. |
You may have to retrieve the HTTP response as a BLOB and evaluate the BLOB.
If it is XML return an XML to JSON transformation.
If if is JSON you know what to do...
On time out catch the time out and create an appropriate JSON to reply with... etc... _________________ MQ & Broker admin |
|
Back to top |
|
 |
whiting |
Posted: Wed Jun 01, 2016 3:12 pm Post subject: |
|
|
Acolyte
Joined: 26 Mar 2002 Posts: 64 Location: Greenville, SC
|
If I get a reply message from the MQ backend, then everything works fine. I create a JSON response out of the MQ response and return the JSON via an HTTP Reply node.
If I catch the timeout and create a message body as JSON, then the message flow still returns HTML to the http client.
I can setup my own timeout and return a "timeout" error via HTTP Reply, but I was trying to use the HTTP Input node timeout functionality rather than working around it. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jun 02, 2016 4:13 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
If you want to return anything else than the standard, you need to map the timeout terminal, create the response message and return it through the HTTP Reply node... If that does not give you the expected response, open a PMR  _________________ MQ & Broker admin |
|
Back to top |
|
 |
whiting |
Posted: Thu Jun 02, 2016 5:44 am Post subject: |
|
|
Acolyte
Joined: 26 Mar 2002 Posts: 64 Location: Greenville, SC
|
That is exactly what I did.
I thought that should have worked, the infocenter didn't help.
OK, I guess it's time for a PMR.
Thanks! |
|
Back to top |
|
 |
whiting |
Posted: Thu Jun 02, 2016 7:42 am Post subject: |
|
|
Acolyte
Joined: 26 Mar 2002 Posts: 64 Location: Greenville, SC
|
I found the solution:
Connect to the HTTP Timeout terminal.
Create the message body in JSON format, but also Add an HTTPReplyHeader with the ContentType set to 'application/json'
When I did that, I got the Json formatted error reply at the client. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jun 02, 2016 8:29 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
whiting wrote: |
I found the solution:
Connect to the HTTP Timeout terminal.
Create the message body in JSON format, but also Add an HTTPReplyHeader with the ContentType set to 'application/json'
When I did that, I got the Json formatted error reply at the client. |
it all has to do with the ReplyHeader and the ContentType... _________________ MQ & Broker admin |
|
Back to top |
|
 |
|