Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to get the http response code from the exchange

101 views
Skip to first unread message

jason.co...@gmail.com

unread,
Dec 16, 2022, 11:53:07 AM12/16/22
to ipf-user
Good morning,

In the iheclient tutorial example, if I wanted to get the actual https response code from the exchange, how would I go about doing that?

Is there a place in the either of the send() methods where I could pull that code?  I've already tried various permutations of result.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE,Integer.class) and the like, but have never gotten a value back from that.  No 200, 404, anything.

Thanks
Jason

Michael Knapp

unread,
Dec 17, 2022, 8:11:24 AM12/17/22
to ipf-...@googlegroups.com
try result.getMessage().getHeader(AbstractWsEndpoint.INCOMING_HTTP_HEADERS)

Michael
 

Dmytro Rud

unread,
Dec 17, 2022, 8:28:33 AM12/17/22
to ipf-...@googlegroups.com
Hi Jason

You can deploy a CXF interceptor (see https://oehf.github.io/ipf-docs/docs/ihe/wsCustomInterceptors) in the incoming and incoming-fault chains on the client side.
This interceptor's method "handleMessage" will get a CXF message as parameter.
A CXF message is a map.
Its entry with the key "HTTP.RESPONSE" contains a value of the type javax.servlet.http.HttpServletResponse.
Method "getStatus" of this value object will return you the HTTP response code.

image.png

Best regards
Dmytro


--
You received this message because you are subscribed to the Google Groups "ipf-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ipf-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ipf-user/f9178fd1-11bf-4b5a-bbb5-1b2f660f529bn%40googlegroups.com.

Dmytro Rud

unread,
Dec 17, 2022, 8:40:30 AM12/17/22
to ipf-...@googlegroups.com
...an alternative would be to propagate this value from CXF to Camel, i.e. to make it available through a Camel message header analogously to AbstractWsEndpoint.INCOMING_HTTP_HEADERS already mentioned in this thread.  
This would require a change in org.openehealth.ipf.platform.camel.ihe.ws.AbstractWsProducer#process -- please feel free to submit a pull request or to create a feature request.

Best regards
Dmytro

jason.co...@gmail.com

unread,
Dec 19, 2022, 9:29:13 AM12/19/22
to ipf-user
I had a feeling this was going to go towards an interceptor.  Thanks everyone.
Reply all
Reply to author
Forward
0 new messages