Discussion (7)3
Log in or sign up to continue

Do you mean the format as in HL7, FHIR, etc.? There are specific ContentType settings for those in the specification, I believe.

  • If the message is a "vertical bar" encoded HL7 v2.x message, the content type SHALL be:     x-application/hl7-v2+er7
  • If the message is an XML encoded HL7 v2.x message, the content type SHALL be:     x-application/hl7-v2+xml
  • If the message is an XML encoded HL7 v3 message, the content type SHALL be:     x-application/hl7-v3+xml
  • If the message is an XML encoded FHIR message, the content type SHALL be:     x-application/fhir+xml
  • If the message is a JSON encoded FHIR message, the content type SHALL be:     x-application/fhir+json
  • If the message is a CDA document, the content type SHALL be:     x-application/xml+cda

Please provide more context and details when you post questions.

To get the request submitted body (if any) you can use the Content property of the %CSP.Request object (i.e. %request).

For the response it's not possible, the response is "sent to the browser" (via Web Gateway....) immediately, there is no buffer or anything.

If you want to capture YOUR response, put it in a buffer and when you are done, send it from your buffer "to the browser"

Hello @Enrico Parisi 

I'm working on capturing and logging all REST request and response data for application endpoints. Currently, I'm able to extract the incoming request using the %request object and handle it within the OnPreDispatch method. My goal is to serialize this request into raw HTTP format for storage and analysis. So, I'm if any method available to create the HTTP format,If no built-in method exists to generate the raw HTTP request format, I plan to implement one manually.

The challenge arises from the manually created REST services are implemented: each REST call directly maps to a class method invocation <Route Url="/test" Method="POST" Call="User.Sample:Test" Cors="true"/> , As a result, capturing the response data would require modifying multiple class methods to intercept output, which is not feasible.

To avoid this, I'm looking for a way to extract the full HTTP response—ideally from a buffer it's been written and accessible, I specifically want to avoid enabling HTTP tracing on the Web Gateway due to performance and logging concerns.

Thanks!

REST code write the response to the current device.

An idea (to be tested) could be to intercept the calls in early stages, save the current device and change the current device to "some other device" (to be defined), then, after the code has finished, save the output to your log and switch to the "old" current device and write the output.

I think it can be done, it surely have some performance impact but...maybe feasible.