Leave feedback
  • Discussion

    base64 encoded attachments in xmlout?

Enter a new topic
  • Anders Ekstrom Anders Ekstrom
    0 likes 3654 views

    From an xml-stream containing both document data for invoice specification and data for e-invoicing (bgc-invoice format) i need to create an xml with the corresponding document for the invoice attached/included as CDATA section (pdf data is base64 encoded).
    E.g.
    Infile (simplified example):
    <inputfile>
     <transaction>
      <docdata textondocument="please pay us $400"/>
      <einvdata ocr="432435" amount="400"/>
     </transaction
     <transaction>
      <docdata textondocument="please pay us $200"/>
      <einvdata ocr="432432" amount="200"/>
     </transaction
    </inputfile>

    The output should be one xml in style like this:

    <output>
     <einvdata ocr="432435" amount="400">
     <![CDATA[
      (docdata as base64 encoded pdf)
     ]]>


     </einvdata>
     <einvdata ocr="432432" amount="200">
     <![CDATA[
      (docdata as base64 encoded pdf)
     ]]>
     </einvdata>
    </output>


    Question:
     - How do i achieve this in the best way? Best way, as I see it, would be to be able to do this straight forward without reprocessing and to put nothing on disk.
     - I would like to post process as well, is that possible?
     - solution must work in cluster environment.


    Other suggestions? Have anyone done this? Is there a sample project?

    Monday 18 January, 2010
  • Peter Martens Peter Martens StreamServe Employee
    0 likes

    Hi Anders,

    A long time ago I created a Quik Guide with an example on how to do this, but I wasn't able to find it back. It should be somewhere on this KB.

    Regards,

    Peter

    Monday 18 January, 2010
  • Vyv Lomax Vyv Lomax Administrator
    0 likes

    Jesper Werge has done this at one customer using high volumes. Please contact him (jwe01).

    Monday 18 January, 2010
  • Jens Hansen Jens Hansen StreamServe Employee
    0 likes

    Anders,

    Is it the PDF you just created in from the received XML that needs to be added into the new XML file as base64 code?

    Monday 18 January, 2010
  • Anders Ekstrom Anders Ekstrom
    0 likes

    Exactly (and I need to run it through pageout and a pdf-driver as well before adding it to the outputstream). //A

    Monday 18 January, 2010
  • Anders Ekstrom Anders Ekstrom
    0 likes

    Thank you very much Jesper! I will post this to the KC.

    Your answers assumes that files are already existing on disk when job runs-  but it should perhaps be possible to have the timing correctly and call the process that makes the pdf on disk before calling the process that generates the xml (the do arrive in the same message actually).

    //Anders

    Monday 18 January, 2010
  • Jukka Brunfeldt Jukka Brunfeldt StreamServe Employee
    0 likes



    From: Ekstrom, Anders
    Posted: Friday, November 14, 2008 5:02 PM
    Subject: base64 encoded attachments in xmlout?

    Thank you very much Jesper! I will post this to the KC.

    Your answers assumes that files are already existing on disk when job runs-  but it should perhaps be possible to have the timing correctly and call the process that makes the pdf on disk before calling the process that generates the xml (the do arrive in the same message actually).

    //Anders

    From: Werge, Jesper
    Sent: den 13 november 2008 14:53
    To: Ekstrom, Anders
    Subject: RE: base64 encoded attachments in xmlout?

    Hi Anders,

    Questions answer is YES YES YES YES J

    It is actually very simple, I used the build-in StreamServe function to encode the file:

    Before message script I placed the:

    $Check = Base64EncodeFile($TIFF_BASE_DIR+ “\myfil.tif”, TIFF_ENDCODED_BASE_DIR + “\encoded_myfil.tif”);

    You can use $Check to see if the result I ok, before proceding or using callproc, so you have a change of failure situation.

    In the xmlOUTprocess, in the exact xml tag, create an variable and place this code:

    OutPutFile($TIFF_ENDCODED_BASE_DIR + $EDI_DC_IDOC_ID +$TIFF_SUFFIX); //link to the encoded file from above.

    If you want this to run on cluster – make sure that the library/folder you want to use for the endcoded files – reading and writing are a shared resource, else you will not be able to control this, if your cluster is linux, this should not be a problem, on windows I have no idea how to do this J

    Is this enough for you for now or…?

    Venlig hilsen

    Jesper Werge

    From: Ekstrom, Anders
    Posted At: den 13 november 2008 14:35
    Posted To: Discussions - XML
    Conversation: base64 encoded attachments in xmlout?
    Subject: base64 encoded attachments in xmlout?

    Exactly (and I need to run it through pageout and a pdf-driver as well before adding it to the outputstream). //A

    From: Hansen, Jens
    Posted At: den 4 november 2008 15:07
    Posted To: Discussions - XML
    Conversation: base64 encoded attachments in xmlout?
    Subject: base64 encoded attachments in xmlout?

    Anders,

    Is it the PDF you just created from the received XML that needs to be added into the new XML file as base64 code?

    Hi, Funny function is AttachementBegin. Do like this Before script of PDF prosess $f=AttachmentBegin(); Then After script of PDF process Base64EncodeFile($f,".\out\encoded.enc"); Then in xml CDATA add function OutputFile(".\out\encoded.enc"); Then you get PDF file as base64 coded in XML-file. Test well before you put that on production ;-) JBr
    Monday 18 January, 2010
  • Anders Ekstrom Anders Ekstrom
    0 likes

    Monday 18 January, 2010
  • Anders Ekstrom Anders Ekstrom
    0 likes

    Monday 18 January, 2010