cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the content type in java mapping

Former Member
0 Kudos

Hi Experts,

I am getting incoming message content type as application/json, I want to change the content type of the output payload from application/json to application/xml in java mapping please suggest me how can i achieve this in java mapping.

Regards,

Rachana.

Accepted Solutions (1)

Accepted Solutions (1)

sunilchandra007
Active Contributor

You can check method setContentType as described in

Regards,

Sunil Chandra

JaySchwendemann
Active Contributor
0 Kudos
public void transform(TransformationInput in , TransformationOutput out) throws StreamTransformationException {
try {
[...]
out.getOutputHeader().setContentType("application/xml"); //for example
} catch (Exception e) { throw new StreamTransformationException("Error"); } }

(Just in case the linked Blog gets send to nirvana due to the next inevitable change of the community software by SAP. Cheers)

Answers (2)

Answers (2)

iaki_vila
Active Contributor
0 Kudos

Hi Rachana,

As far as i know there is no standard bean functionality to transform json, You can try with an own module bean or a java mapping and to translate from json to XML. You can find some examples on internet:

Heshan's Blog: Java library to convert XML to JSON

Converting JSON to XML in Java - Stack Overflow (you would need to import the library)

Regards.

javier_alcubilla
Contributor
0 Kudos

You can do it in the receiver adapter with MessageTransformBean module