Question

I am using Wso2esb 4.7.0 we have option in this set a property with Json how we can set if in xml we can set like this

<property name="username"
                   expression="//username/text()"
                   scope="default"
                   type="STRING"/>

for payload factory

<payloadFactory>
            <format>
               <p:login xmlns:p="http://authentication.services.core.carbon.wso2.org">
                  <p:username>$1</p:username>
                  <p:password>$2</p:password>
                  <p:remoteAddress>$3</p:remoteAddress>
               </p:login>
            </format>
            <args>
               <arg expression="//username/text()"/>
               <arg expression="//password/text()"/>
               <arg expression="get-property('client_ip_address')"/>
            </args>
         </payloadFactory>

how we can achieve it with JSon I tried with this property

    <property name="faisal" expression="$name/text()" scope="default"/>

but its not working and can we pass this JSON through Wso2dss please let me know

No correct solution

OTHER TIPS

If you are using 'ESB 4.7' it comes with default 'JSON' support, meaning the conversion to 'XML' should happen. You will set the property the same as you would for the 'XML' being passed.

  <login><username>JohnDoe</username><pass>yourPass</pass><login> == {“login”:{“username”: ”JohnDoe”,      "pass" : "yourPass"}}

     <property name="username"
               expression="//login/username/text()"
               scope="default"
               type="STRING"/>

Another option that will work if you want to keep the 'JSON' message intact without converting to XML which saves on performance you can use the 'evaluator'. There are a couple of things you need to do on the server to enable this feature. Un comment the 'MessageFormatter' & 'MessageBuilder' in the axis2.xml (The link I provided has those details)

 <arg expression="$.login.username" evaluator="json"/>

Detailed Explanation & Example here : http://docs.wso2.org/wiki/display/ESB470/PayloadFactory+Mediator

Eventhough you are sending JSON input message, the message passed inside the ESB service is SOAP. So same property definition can be used in this case as well.

<property name="username"
                   expression="//username/text()"
                   scope="default"
                   type="STRING"/> 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top