Question

Please help me on this error.I have captured original payload through session variable in mainflow.In case of error scenario's, I have another subflow, where i have used Message Property Transformer and XSLT transformer. So when i try to put wrongly formatted xml( trying to create parser exception).In XSLT transformer throwing error like "Element type "messageNamestr1234" must be followed by either attribute specifications, ">" or "/>" ".

Actually my logic is, in error scenario's i supposed to construct the xml - in that one of the filed need to capture original payload.In all other testing scenario it seems to be working fine( properly xml is generated). But only for parser exception, messages is not propagating in to the queue since XSLT throwing error. Please find my config xml

        <flow name="mainFlow" doc:name="MessageFlow"
    tracking:enable-default-events="true">

    <wmq:inbound-endpoint queue="InQUEUE"
        tracking:enable-default-events="true" connector-ref="WMQ_Connector"
        doc:name="queue" doc:description="Flow">
        <wmq:transaction action="ALWAYS_BEGIN" />
    </wmq:inbound-endpoint>
    <byte-array-to-string-transformer doc:name="Byte Array to String"/>
    <set-session-variable variableName="originalPayload" value="#[payload]" doc:name="Store_Payload"/> 
    <logger message="***change*#[message.payloadAs(java.lang.Object)]*****" level="INFO" doc:name="Logger"/>
    <mulexml:dom-to-xml-transformer></mulexml:dom-to-xml-transformer>
              <set-session-variable variableName="operation"
        value="#[xpath('fn:local-name(/root/*[2])')]" doc:name="Set_Operation" doc:description="separate Operation"/>       
    ..........
    <choice-exception-strategy doc:name="Choice Exception Strategy" doc:description="used to differenciate system and application error">
        <catch-exception-strategy doc:name="Catch_ApplicationFailure_Messages"
            when="#[exception.causedBy(org.mule.api.MessagingException)]" doc:description="Catches all the application errors and call the error handling subflow to log the error messages">
            <flow-ref name="Common_ErrorHandling_SubFlow" doc:name="Invoke_Common_ErrorHandling_SubFlow" />
        </catch-exception-strategy>

        <rollback-exception-strategy
            maxRedeliveryAttempts="3" doc:name="Catch_SystemFailure_Messages" doc:description="Message Processor catches system error and tries to retry for 3 times and finally put the message in queue"> 
        ................        
        </rollback-exception-strategy>
    </choice-exception-strategy>
</flow>

     <sub-flow name="Common_ErrorHandling_SubFlow" doc:name="Common_ErrorHandling_SubFlow"
    tracking:enable-default-events="true">

    <logger message="***enetered**" level="INFO" doc:name="Logger"/>

    <message-properties-transformer
        doc:name="Catch_MessageProperties" doc:description="Used to capture project and message specific information" scope="outbound">

        <add-message-property key="InterfaceName" value="'Requests'" />
        <add-message-property key="ProjectName" value="'NewProject'" />
        ..........
        <add-message-property key="JMSMessageID"
            value="#[header:INBOUND:JMSMessageID]" />
        <add-message-property key="MuleMessageID"
            value="#[header:INBOUND:MULE_MESSAGE_ID]" />
        <add-message-property key="ExceptionPayload"
            value="#[exception]" />
        <add-message-property key="originalPayload" value="#[sessionVars.originalPayload]"/>
    </message-properties-transformer>
    <byte-array-to-string-transformer doc:name="Byte Array to String"/>

    <mulexml:xslt-transformer
        maxIdleTransformers="2" maxActiveTransformers="5"
        doc:name="Generate_ErrorXmlStructure" xsl-file="XSLTScript.txt" doc:description="XSLT transformer used to generate standard xml message with its scripts">
        <mulexml:xslt-text>
        </mulexml:xslt-text>

        <mulexml:context-property key="ProjectName"
            value="#[header:OUTBOUND:ProjectName]" />
        .........
        <mulexml:context-property key="DetailsExceptionMessage"
            value="#[header:OUTBOUND:DetailsExceptionMessage]" />
        <mulexml:context-property key="OriginalPayload"
            value="#[header:OUTBOUND:originalPayload]" />
        <mulexml:context-property key="MessageInDate"
            value="#[header:OUTBOUND:MessageInDate]" />
        <mulexml:context-property key="InputQueue"
            value="#[header:OUTBOUND:InputQueue]" />
    </mulexml:xslt-transformer>

    <wmq:outbound-endpoint queue="ERROR"
        connector-ref="WMQ_Connector" doc:name=".ERROR" doc:description="Used to log error messages">
        <wmq:transaction action="ALWAYS_JOIN"/>
    </wmq:outbound-endpoint>
</sub-flow>

Assumption:since it is parser exception, XSLT Transformer excepting standard xml structure (in capturing payload). So thought to route in CDATA.Not sure how to do it.Also tried various options in context properties in XSLT transformer

       1. <mulexml:context-property key="OriginalPayload"
            value="#[message.outboundproperies.originalPayloadAs(java.lang.Object)]" /> 
       2.<mulexml:context-property key="OriginalPayload"
            value="#[header:SESSION:originalPayload]" />
       3.<mulexml:context-property key="OriginalPayload"
            value="#[!CDATA[sessionVars.originalPayload]]" />

but no hope.Kindly help me on this.

@DavidDossot: I have added my XLST scipt and i changed the parameters as you suggested.

      <xsl:stylesheet version="2.0"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
                    <xsl:output omit-xml-declaration="yes" cdata-section-elements="OriginalPayload" />
                    <xsl:param name="InterfaceName" />
                    <xsl:param name="ProjectName" />
                       ..........
                    <xsl:param name="OriginalPayload" />
                    <xsl:param name="MessageInDate" />
                    <xsl:template match="*">
                        <Specific>
                            <ProjectName>
                                <xsl:value-of select="$ProjectName" />
                            </ProjectName>
                            <InterfaceName>
                                <xsl:value-of select="$InterfaceName" />
                            </InterfaceName>
                                .......
                           <OriginalPayload>
                            <xsl:value-of select="$OriginalPayload"/>
                        </OriginalPayload> 
                 </Specific>
                    </xsl:template>
                </xsl:stylesheet>

also in Context properties i have added

                    <mulexml:context-property key="OriginalPayload"
            value="#[sessionVars.originalPayload]" />

Still i'm facing the same error. I have tried multiple options 1.Removed omit-xml-declaration 2.Edited many properties in xslt and tried. No hope. Kindly guide me where i have gone wrong.

@DavidDossot please find my input xml ( removed > from messageName filed to check parser exception behaviour in flow)

   <?xml version="1.0" encoding="utf-8"?>
   <root>
   <header>
   <messageName>str1234</messageName>
   <messageId>12345</messageId>
   <storeNo>123</storeNo>
   <storeElement>str1</storeElement>
   <requestDateTime>2012-12-13T12:12:12</requestDateTime>
   </header>
   <Request>
   <messageNamestr1234</messageName>
   </Request>
   </root>

Please guide me.

Était-ce utile?

La solution

Since the original payload is a string, you should be able to pass it to the XSL-T directly with:

<mulexml:context-property key="OriginalPayload"
        value="#[sessionVars.originalPayload]" />

Then in your XSL output configuration, put the name of the XML element that will contain the original payload in cdata-section-elements:

<xsl:output cdata-section-elements="yourElementNameHere"/>

PS. header:OUTBOUND is deprecated use message.outboundProperties.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top