WSO2ESB:属性设置不接受空值 [英] WSO2ESB: Property setting not accepting empty value

查看:92
本文介绍了WSO2ESB:属性设置不接受空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,当我在WSO2 ESB中的序列中使用空字符串设置属性时,我试图获取一个空值.我尝试了很多事情,但是在获取属性时总是得到结果为"null"或"\" \"而不是",这是我的代码:

Actually I'm trying to get an empty value when I set a Property in a sequence in WSO2 ESB with an empty string. I have tried many things but always get the result "null" or "\"\"" instead of "" when I get the property, here is my code:

<property value="&quot;&quot;"
name="arq.general.DestinationSystem" scope="default"
type="STRING" xmlns:ns="http://org.apache.synapse/xsd" 
xmlns:ns2="http://org.apache.synapse/xsd"/>
<property name="arq.general.ParentInstanceID" scope="default"
type="STRING" value=""/>
<property expression="get-property('NonExistentProperty')" 
name="arq.functional.User"
scope="default" type="STRING"
xmlns:ns="http://org.apache.synapse/xsd" 
xmlns:ns2="http://org.apache.synapse/xsd"/>

请您帮忙?

干杯

托尼

++有效负载工厂:

<payloadFactory media-type="xml">
            <format>
                <MensajeAuditoria xmlns="">
                    <Timestamp>$1</Timestamp>
                    <TrackingID>$2</TrackingID>
                    <SourceApplication>$3</SourceApplication>
                    <OperationName>$4</OperationName>
                    <ParentInstanceID>$5</ParentInstanceID>
                    <InstanceID>$6</InstanceID>
                    <ServiceID>$7</ServiceID>
                    <FunctionalID>$8</FunctionalID>
                    <AdapterType>$9</AdapterType>
                    <AdapterPoint>$10</AdapterPoint>
                    <HostName>$11</HostName>
                    <User>$12</User>
                </MensajeAuditoria>
            </format>
            <args>
                <arg evaluator="xml" expression="get-property('SYSTEM_TIME')"/>
                <arg evaluator="xml" expression="get-property('arq.general.TrackingID')"/>
                <arg evaluator="xml" expression="get-property('arq.general.SourceApplication')"/>
                <arg evaluator="xml" expression="get-property('arq.functional.OperationName')"/>
                <arg evaluator="xml" expression="get-property('arq.general.ParentInstanceID')"/>
                <arg evaluator="xml" expression="get-property('arq.general.InstanceID')"/>
                <arg evaluator="xml" expression="get-property('arq.general.ServiceID')"/>
                <arg evaluator="xml" expression="get-property('arq.functional.FunctionalID')"/>
                <arg evaluator="xml" expression="get-property('arq.general.AdapterType')"/>
                <arg evaluator="xml" expression="$func:AdapterPoint"/>
                <arg evaluator="xml" expression="get-property('SERVER_IP')"/>
                <arg evaluator="xml" expression="get-property('arq.functional.User')"/>

            </args>
        </payloadFactory>
    </else>
</filter>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>

添加出厂结果:

{
"MensajeAuditoria": {
    "Timestamp": 1492777451830,
    "TrackingID": "76b9858d-8421-4d7e-d2af-e8e411382e2e",
    "SourceApplication": "API Manager",
    "OperationName": null,
    "ParentInstanceID": null,
    "InstanceID": "76b9858d-8421-4d7e-d2af-e8e411382e2e",
    "ServiceID": "PRX_PROY1_AEX_AltaCliente",
    "FunctionalID": null,
    "AdapterType": "AEXP",
    "AdapterPoint": "PreActRequest",
    "HostName": "172.16.3.97",
    "User": null,
}}

推荐答案

Good thing would be to use enrich mediator to map the json field to xml field if there is a vale for the incoming field.
Sample
      <filter regex="true" source="boolean(get-property('START_DATE'))">
        <then>
          <enrich description="Add startDate tag">
            <source clone="true" type="inline">
              <org:startDate xmlns:org="urn:example.com/service/org"/>
            </source>
            <target action="child" xpath="//*[local-name()=get-property('RequestType')]"/>
          </enrich>
          <enrich description="populate startDate">
            <source clone="true" property="START_DATE" type="property"/>
            <target
              xmlns:org="urn:example.com/servi`enter code here`ce/org" xpath="//org:startDate"/>
          </enrich>
        </then>
        <else/>
      </filter>

这篇关于WSO2ESB:属性设置不接受空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆