0

I am stuck on creating an output message from wso2 esb 5.0. The correct form of the message should be:

<request lang="11" user="user" pwd="pwd">
    <query dateformat="%d-%m-%Y" maxrecords="100">
    <tables>
        <table tablename="Company"/>
    </tables>
    <condition>
        <cond tablename="Company" fieldname="Upd" op="&gt;" value="10.11.2016"/>
        <cond tablename="Company" fieldname="UpdTime" op="&gt;" value="01:00"/>
    </condition>

The fun part is "&gt;" in the "op" attribute. There has to be "&gt;" and not ">". CDATA and this character also doesn`t work:

&#38;

I tried with payload factory, xslt transformation and script mediator with different values but with no success. My bad attempts:

<payloadFactory description="Create Request" media-type="xml">
<format>
        <request lang="11" user="user" pwd="pwd">
                <query dateformat="%d-%m-%Y" maxrecords="100">
                <tables>
                    <table tablename="Company"/>
                </tables>
                <condition>
                    <cond tablename="Company" fieldname="Upd" op="&gt;" value="07.10.2016"/>
                    <cond tablename="Company" fieldname="UpdTime" op="&gt;" value="01:00"/>
                </condition>
            </query>
        </request>
        </format>
    <args/>
</payloadFactory>

With XSLT:

<xslt description="Create Request" key="get-companies"/>


<localEntry key="get-companies" xmlns="http://ws.apache.org/ns/synapse">
<xsl:stylesheet exclude-result-prefixes="ws" version="1.0" xmlns:ws="http://ws.company.com/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output encoding="UTF-8" indent="yes" method="xml" omit-xml-declaration="no"/>
    <xsl:template match="/">
        <xsl:element name="request">
            <xsl:attribute name="lang">11</xsl:attribute>
            <xsl:attribute name="user">user</xsl:attribute>
            <xsl:attribute name="pwd">pwd</xsl:attribute>
            <xsl:element name="query">
                <xsl:attribute name="maxrecords">100</xsl:attribute>
                <xsl:attribute name="dateformatin">%d-%m-%Y</xsl:attribute>
                <tables xmlns="">
                    <table tablename="Company"/>
                </tables>
                <condition xmlns="">
                    <xsl:element name="cond">
                        <xsl:attribute name="tablename">Company</xsl:attribute>
                        <xsl:attribute name="fieldname">Upd</xsl:attribute>
                        <xsl:attribute name="op">&gt;</xsl:attribute>
                        <xsl:attribute name="value">
                            <xsl:value-of select="07.01.2016"/>
                        </xsl:attribute>
                    </xsl:element>
                    <cond fieldname="UpdTime" op=">" tablename="Company" value="01:00"/>
                </condition>
            </xsl:element>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

Script Mediator:

<script language="js"><![CDATA[mc.setPayloadXML(<request lang="11" user="user" pwd="pwd">
  <query dateformat="%d-%m-%Y" maxrecords="100">
  <tables>
   <table tablename="Company"/>
  </tables>
  <condition>
   <cond tablename="Company" fieldname="Upd" op="&amp;gt;" value="07.01.2016"/>
   <cond tablename="Company" fieldname="UpdTime" op="&amp;gt;" value="01:00"/>
  </condition>
 </query>
</request>); ]]></script>

Please help me to find the correct form.

Community
  • 1
  • 1
Kamil
  • 23
  • 3
  • 1
    The correct form is what you have written in the Payload factory. The trick is to change it in Source mode and not switch to Design mode after saving the file and before exporting the CAR. – Maria Ivanova Nov 10 '16 at 09:59
  • 1
    Yes you are right thanks! :) – Kamil Dec 02 '16 at 18:14

0 Answers0