#1
|
|||
|
|||
![]()
I wish to send back as channel response, a generated document.
As seen around the forum, I created the pdf destination and using a postProcessor script I tried to send it back. Code:
logger.info('http test- MID '+messageObject.getId()); var contents = FileUtil.readBytes('/tmp/http-test/'+channelMap.get('MESSID')+'.pdf'); var encData=FileUtil.encode(contents); var resp= 'application/pdf;base64,'+encData responseMap.put('pdf resp', ResponseFactory.getSuccessResponse(resp)); return; Should Some suggest anything? Thank you. |
#2
|
|||
|
|||
![]()
Hi supertoms,
Did you have any luck figuring this out? I'm having the same problem using version 1.8.1.4211 Could it be that Mirth doesn't allow us to change the headers? Thanks! Last edited by csmith; 01-04-2010 at 09:59 AM. Reason: more info |
#3
|
|||
|
|||
![]()
Hi.
I've tried without success. I can't control the mime type of returned file. The browser still handl it as text or html. I've also tried to included the returned object into an html page, selecting the correct mime type but without success. |
#4
|
|||
|
|||
![]()
see the 4th post in this thread to see if it helps:
http://www.mirthcorp.com/community/f...ead.php?t=3372 I used a postProcessor javascript with that code. Last edited by josealmeida; 01-07-2010 at 08:39 AM. |
#5
|
|||
|
|||
![]()
Thanks for suggestions, but the problem is still open.
I've an http source that receive Response from "pdf resp", a responseMap value declared. My postprocess script is: Code:
logger.info('http test- MID '+messageObject.getId()); logger.info('file '+'/tmp/http-test/'+channelMap.get('MESSID')+'.pdf'); var contents = FileUtil.readBytes('/tmp/http-test/'+channelMap.get('MESSID')+'.pdf'); logger.info('encode'); var encData=FileUtil.encode(contents); //remove the newlines to produce valid Base64 var index = encData.indexOf("\r\n"); while(index != -1){ encData = encData.replace("\r\n",""); index = encData.indexOf("\r\n"); } var resp=encData; responseMap.put('pdf resp', ResponseFactory.getSuccessResponse(resp)); return; In this way, calling http://myserver:8083/?testType=httpTestMirth&value=56 I can see the text data of my pdf on my browser. The returned page generated is a text/html page not pdf. |
#6
|
|||
|
|||
![]()
supertoms: yes, the returned data is text since it is base64 encoded. Decode the data and you have your pdf document.
__________________
Daniel Svanstedt Software Engineer Mirth Corporation Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation: Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As! |
#7
|
|||
|
|||
![]()
Hi,
I've been trying to develop a test channel which listens for an http request and returns a pdf to the client's browser. Here's what I have as a postprocessor script: ************************************************** ************************** var contents = FileUtil.readBytes('/var/www/test.pdf'); var encData=FileUtil.encode(contents); var index = encData.indexOf("\r\n"); while(index != -1){ encData = encData.replace("\r\n",""); index = encData.indexOf("\r\n"); } var resp=FileUtil.decode(encData); resp = 'application/pdf,' + resp; responseMap.put('pdf resp', ResponseFactory.getSuccessResponse(resp)); return; ************************************************** *********************************** When I prompt the channel thusly http://xxxxxx:8111 (the port being configured in the Source), the expected pdf isn't returned, but, rather, a bunch of characters. No errors are logged by the server. I'm using MirthConnect version 1.8.1.4211 Any insights would be hugely appreciated (as always)! |
![]() |
Thread Tools | |
Display Modes | |
|
|