XSLT incomming mapping with base64 payload

Moderator: crythias

Post Reply
lis9
Znuny newbie
Posts: 74
Joined: 13 Apr 2017, 11:27
Znuny Version: 7.1.3
Real Name: Daniel
Company: Komputronik S.A.

XSLT incomming mapping with base64 payload

Post by lis9 »

Hello,

I’m encountering an issue with my outgoing WebService integration. I’m communicating with the DHL Api2 (SOAP) using the getEpod method to retrieve a proof of delivery in PDF format.

The communication works smoothly, and I receive the response correctly. However, I have to store the payload as an article attachment using XSLT mapping, and that’s where I run into trouble.

Here’s the relevant part of my incoming XSLT mapping:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date">
  <xsl:output method="xml" encoding="utf-8" indent="yes"/>
  <xsl:template match="RootElement">
    <xsl:copy>
      <OTRS_TicketArticleAdd>
        <CommunicationChannel>Internal</CommunicationChannel>
        <IsVisibleForCustomer>1</IsVisibleForCustomer>
        <SenderType>system</SenderType>
        <From>root@localhost</From>
        <Subject>Retrieve POD</Subject>
        <Body>
          The POD attachment was successfully imported from the DHL service.
        </Body>
        <ContentType>text/plain; charset=utf-8</ContentType>
        <HistoryType>AddNote</HistoryType>
        <HistoryComment>Technical note – POD attachment retrieved from DHL Api2 has been saved.</HistoryComment>
        <Attachment>
          <Filename>POD.pdf</Filename>
          <ContentType><xsl:value-of select="//getEpodResult/scanMimeType"/></ContentType>
          <Content><xsl:value-of select="//getEpodResult/scanData"/></Content>
        </Attachment>
      </OTRS_TicketArticleAdd>
      <OTRS_TicketDynamicFieldSet_PODApi>0</OTRS_TicketDynamicFieldSet_PODApi>
    </xsl:copy>
  </xsl:template>
</xsl:transform>
Everything works fine except for one thing: the attachment is not stored in the expected PDF format. Instead, its content remains base64-encoded.

Should I modify my mapping to decode the content, or is this a known issue (bug) in the system?

Kind regards,
Daniel Lisiecki
Post Reply