Hello,

I found a problem with the PayloadFactory.

I have the following XML structure generated by an aggregate mediator:

<jsonObject>
        <resourceType>Bundle</resourceType>
    </jsonObject>
    <jsonObject>
        <resourceType>Bundle</resourceType>
        <entry>
            <resource>
            </resource>
            <resource>
            </resource>
            <resource>
            </resource>
        </entry>
    <jsonObject>
    <jsonObject>
        <resourceType>Bundle</resourceType>
        <entry>
            <resource>
            </resource>
            <resource>
            </resource>
        </entry>
    <jsonObject>
</jsonObject>

My goal, is to generate a JSON payload like that:

{ "resourceType": "Bundle", "type": "searchset", "entry": [ <my resources
elements here ] }

To do so, I tried many permutation with the PayloadFactory arg evaluator
and I just conclude that this is bugged because the behaviour does not
follow any logic. Here is one of my PayloadFactory permutation:

<payloadFactory media-type="json">
    <format>{ "resourceType": "Bundle", "type": "searchset", "entry": $1
}</format>
    <args>
        <arg evaluator="xml" expression="//entry/*"/>
    </args>
</payloadFactory>

And the payload is:

{
    "resourceType": "Bundle",
    "type": "searchset",
    "entry": {
        "resource": [
            {}, {}, {}
         ]
      }
}


So, I tried with:

<payloadFactory media-type="json">
    <format>{ "resourceType": "Bundle", "type": "searchset", "entry": $1
}</format>
    <args>
        <arg evaluator="xml" expression="//entry"/>
    </args>
</payloadFactory>

And I have:

{
    "resourceType": "Bundle",
    "type": "searchset",
    "entry": {
        "entry": [
            { "resource": {} }, { "resource": {} } , { "resource": {} }
         ]
     }
}

OK. We are nearly there. So I changed the format of the payloadFactory for:

<format>{ "resourceType": "Bundle", "type": "searchset", $1  }</format>

And I get:

[ { "resource": {} },  { "resource": {} } ,  { "resource": {} } ]

And I am like "What the hell?" because that is exactly what I wanted for $2
in the previous try (the one with the format { "resourceType": "Bundle",
"type": "searchset", "entry": $1  } ). Where are my custom attributes
(resourceType and searchset)?


Have you got an idea of a workaround for that? I could use a JS mediator
but my payload is so huge that Rhino does not want to compile the script.

Regards,

Thomas
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to