2

I'm new to BW6 (v.6.3.1) and I'm playing around with it's REST features. Currently I'm building a very simple echo service to figure out how it processes parameters etc. One of the things I've noticed is that I can specify multiple Reply Client Formats, namely XML & JSON. But I can't find how I can specify what output to use in the actual reply.

Currently I've setup the following Resource Service Path:

/echo/{param}.{format}

I want to use the format parameter to drive the output I'll be getting. So

/echo/printme.xml

would result in

<messageBody>printme</messageBody> (or something to that extent)

And

/echo/printme.json

would result in

printme

I've tried several approaches, splitting the flow based on the contents of "format" but to no avail. If I have JSON checked as the Reply Client Format it will reply with JSON. Only if XML is the only Reply Client Format checked the reply will output XML. BW handles the rendering of either JSON or XML transparently.

So, how can I tell BW to output in either XML or JSON when both are selected as a Reply Client Format?

Edit: Using the swagger UI I figured out how I can drive this behavior. By specifying the following header:

curl -X GET --header "Accept: application/xml" "http://localhost:8080/echo"
Deddiekoel
  • 1,939
  • 3
  • 17
  • 25

1 Answers1

0

As per the documentation

Select the Invoke REST API pallette, you can choose the type(either request or response) as shown below:

enter image description here

If you click on it, there are three options JSON, XML and Custom. If you want to choose other than json and xml then choose Custom.

Custom(For RequestType) : Custom: to override the Content-Type value in the Input tab, select CUSTOM and provide the value in the Input tab.

Custom(For ResponseType): to override the Accept header value in the Input tab, select CUSTOM and provide the value in the Input tab.

Below is the Input tab where you can override when type is Custom:

enter image description here

Rao
  • 20,781
  • 11
  • 57
  • 77
  • This drives the behavior from a client. I was wondering if there is any way to drive the behavior on the service? So can I force a certain type of output? – Deddiekoel Jun 14 '16 at 19:03
  • Provided service has done that way and let the client choose – Rao Jun 15 '16 at 00:39