on 08-07-2014 12:18 PM
Hi folks,
I have scenario where I need to create a PDF-file from a given xml-request. The request get postet to the PI using a proxy object. Then I perform several conversion task in PI and as a response I get a byte-array in response.
When I take this byte-array and convert it useing a base64 decode on the internet, I get the required pdf-file. But I need to save this xml-byte-stream as a pdf-file useing PI The message type looks as follow:
How can I archive to save this PDF_Response as real pdf-file?
thanks in advance
regards
Christian
Hi Christian,
If I have understood your requirement correctly, you should use a java mapping to read the base64 binary data from PDF_Response field from input XML and then decode to binary and write it to output stream (TransformationOutput).
That's all..
Regards,
Praveen Gujjeti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praven,
yes that's correct.
I allready got the response as byte-stream within the mapping, because this is the response from a another server.
Now the two remaining questions are:
regards
Christian
Hi,
In java mapping,
read the base64 textual data from 'PDF_Response' field of input XML --> decode it to binary stream (data) and then write it to output stream (TransformationOutput).
In the receiver file channel give some test.pdf as file name. And then check the generated file with acrobat reader
Regards,
Praveen Gujjeti
Hi Christian,
Once you have the Byte[] data you can call the file system operations directly from the mapping and save it the location where you want it to be.
Something like this: (within an UDF):
File f = new File("\\XXX\BBB\response.pdf";
FileOutputStream fos = new FileOutputStream(f);
fos.write(byte[]);
fos.close();
Place appropriate try{}catch{} block.
Hope it helps!
Cheers,
Anand Patil
Hi,
ok but now I have one question left. I have implemented the source code within a UDF as I need to pass several values to the funtion during mapping execution.
Can I use the TransformationOutput also within the UDF? Currently I have done all the required steps and performed the decryption. The byte-stream looks good but when I try to pass it as output I get the following error:
Do I need to convert the UDF to a real java function? Can I then pass several values to this function?
regards
Christian
Hi Christian,
You can directly convert the Base64Decode to String and pass it to the output message type using your UDF (as you are doing some other conversions...) Then you can use a simple java mapping to transfer the payload to outputstream in which you can convert it back to stream. This would require 2 message mappings in your operation mapping. Just a thought!
Cheers,
Anand
Hi there,
you were completly wright with the pure java-mapping. I did this and it worked in the first time. But the I made a change wihin the mapping code and re-deployed the jar file. Now I'm getting the below error:
Any clue how this error can be resolved? As I set the mapping worked fine for the first time...
regards
Christian
Once again you were wright! I deleted the second imported archive in the ESR. Although the class is imported and included in my jar file it also needs to be imported as imported archive in the ESR... I imported the archive and now everything is working as expected.
Thanks a lot!
regards
Christian
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.