Hi All,
I am working on a synchronous scenario where I am sending an HTTP request to third party and I am getting back the response. My requirement is that I need to pass through this response as it is from XI, no transformation is required.
This happens twice:
1) In first case, I receive the html data which is ok
2) in second case, I receive PDF data which is getting corrupted and I cant view that pdf data after my message mapping.
I am using below code in response mapping (java mapping)....
public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException {
try {
String sourceString = "";String line ="";
String append ="";
InputStream ins = in.getInputPayload().getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(ins, "UTF-8"));
while ((line = br.readLine()) != null){
sourceString = sourceString + line;
}
br.close();
out.getOutputPayload().getOutputStream().write(sourceString.getBytes("UTF-8"));
}
catch (Exception e) {
throw new StreamTransformationException(e.getMessage());
}
}
Problem is that this code is working for case 1) when I receive HTML data but in case 2) the data gets corrupted.I think I would need to pass the response as binary data (as it is) for both the cases.
Do not forget that it is a synchronous interface so I do not have the option to bypass the IR development since I am making some transformation in the request mapping.
Can anyone suggest.
Thanks,
Ravi.