on 09-18-2013 9:02 PM
Hi, we have an outbound email setup which is converting an XML payload to an attachment.
Sometime after the mapping it is converting some of our escaped content to a different format and it is causing trouble.
In the email receiver adapter we are running the message through XMLAnonymizer also.
I can confirm the Integration Engine Mapping is leaving it untouched.
How can I get the adapter / beans to preserve < and > instead of codes < and =?
Many thanks,
Aaron
Thanks again Baskar, feel like I'm getting very close now, but I'm not familiar with this XSLT format. I'm trying to learn it but in the mean time if anyone knows the answer I will appreciate it.
I have source structure like:
<?xml version="1.0" encoding="utf-8"?>
<nfeProc xmlns="http://www.portalfiscal.inf.br/nfe">
...
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
....
</Signature>
....
</nfeProc>
The PI mapping is changing it to:
<?xml version="1.0" encoding="utf-8"?>
<ns0:nfeProc xmlns:ns0="http://www.portalfiscal.inf.br/nfe">
...
<ns1:Signature xmlns:ns1="http://www.w3.org/2000/09/xmldsig#">
....
</ns1:Signature>
....
</ns0:nfeProc>
This is invalidating the digital signature. XML Anonymizer was working perfectly for cleaning up these namespace prefixes but it has an unintended consequence of changing some characters in a free form CDATA string from < to & #60 ; notation.
So I tried to use this XSLT instead of XMLAnonymizer which gets very close, but it is removing the xml namespace of the Signature...which I need.
XSL:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://www.portalfiscal.inf.br/nfe"
xmlns="http://www.portalfiscal.inf.br/nfe"
xmlns:ns1="http://www.w3.org/2000/09/xmldsig#"
>
<xsl:output method="xml" indent="no"/>
<xsl:template match="ns0:*|ns1:*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Result:
<?xml version="1.0" encoding="utf-8"?>
<nfeProc xmlns="http://www.portalfiscal.inf.br/nfe">
...
<Signature>
....
</Signature>
....
</nfeProc>
The main problem now, this is removing the " xmlns="http://www.w3.org/2000/09/xmldsig#" from Signature element. Also this whole XSL approach seems to be combining some elements like:
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform>
gets shortened to:
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
I know this logically equivalent but I would rather preserve everything in the original XML as is. There must be an easier way!
All I really want to do in this whole scenario is send an XML payload unchanged as an email attachment. I must use a mapping to set dynamic configuration variables of mail adapter. Mapping is introducing namespace prefix changes to XML. Then trying to undo those, XML Anonymizer introduced further changes to freeform CDATA XML. Seems the XSLT approach is also causing side effects.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Final solution, add XSLT mappings to the end of the relevant Operation Mapping.
1) Get rid of ns0 with first XSLT map"
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="[-put namespace you want to use here-]"
xmlns="[-put namespace you want to use here-]"
>
<xsl:output method="xml" indent="no"/>
<xsl:template match="ns0:*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
2) Do similar with any other PI namespace you want to replace like ns1
<?xml version="1.0" encoding="utf-8" ?>
</xsl:element>
</xsl:template>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
3) XMLAnonymizer was no longer needed in our case.
Sorry guys, I found this issue isn't with the email adapter itself. When I take the XML Anonymizer bean out of the loop the issue goes away.
However, I still need to get rid of the extra namespaces PI is adding. Any more ideas considering this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What do you do with XMLAnonymizer bean ? Are you removing extra namespace? Are you changing the encoding of the message using anonymizer.encoding? The other simplest idea is to use xslt mapping to get rid of the extra namespace. This is an easier solution.
You might also check this blog and the questions below...
Thats right Baskar, I'm using XML Anonymizer bean to get rid of extra namespaces. I haven't intentionally changed any encoding using that parameter. It is working correctly for removing the namespaces but one segment sometimes gets this extra CDATA xml string and it is getting treated differently here in PI.
I've never used an XSLT mapping before but I may give that a try instead of the bean.
So this example XSLT is working to wipe out all namespaces... I want to only get rid of "ns0" prefix for now. Any help paring it down is appreciated!
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no"/>
<xsl:template match="/|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
Please try this thread way... Basically I don't know your structure....
You have to use your namespace prefix accordingly in the code. Example:( here it is given as xmlns:xenc ) (xenc is prefix).
Please check whether the editor you view the attachment has issue. Just to make sure , you can try with different editor to view the attachment.Also check whether content encoding type is changed in your bean level (if any) instead UTF-8
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You might want to check this SAP document and suggested note for the content type encoding setup in mail adapter
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
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.