Hi Madhawa,

Thanks for the response. Yes, we can pass a null value as you suggested,
But think of a scenario, there are a lot of elements in the payload which
can be null. Then its hard to handle like this.  +1 to fix this.


Thanks
Godwin

On Thu, Mar 8, 2018 at 1:15 PM, Madhawa Gunasekara <[email protected]>
wrote:

> Hi Godwin,
>
> You can try below-mentioned way to pass the null value correctly to the
> data service. IMO, We need to fix this issue. It's not correct to evaluate
> JSON null value as String "null"
>
> <filter xpath="string(get-property('Id')) != 'null'">
>             <then>
>          <payloadFactory media-type="xml">
>              <format>
>                <m1:updateForOperation xmlns:m1="http://www.test.com.";>
>                   <m1:iId>$1</m1:iId>
>                   <m1:iBitrixDealId>$2</m1:iBitrixDealId>
>                   <m1:iBitrixContractId>$3</m1:iBitrixContractId>
>                </m1:egateUpdateForBitrixOperation>
>             </format>
>             <args>
>                <arg evaluator="xml" expression="get-property('Id')"/>
>                <arg evaluator="xml" expression="get-property('DealId')"/>
>                <arg evaluator="xml" expression="get-property('
> ContractId')"/>
>             </args>
>          </payloadFactory>
>      </then>
>      <else>
>         <payloadFactory media-type="xml">
>              <format>
>                <m1:updateForOperation xmlns:m1="http://www.test.com.";>
>                   *<m1:iId
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
> <http://www.w3.org/2001/XMLSchema-instance>" xsi:nil="true"/>*
>                   <m1:iBitrixDealId>$1</m1:iBitrixDealId>
>                   <m1:iBitrixContractId>$2</m1:iBitrixContractId>
>                </m1:egateUpdateForBitrixOperation>
>             </format>
>             <args>
>                <arg evaluator="xml" expression="get-property('DealId')"/>
>                <arg evaluator="xml" expression="get-property('
> ContractId')"/>
>             </args>
>          </payloadFactory>
>      </else>
>  </filter>
>
> Thanks,
> Madhawa
>
> On Wed, Mar 7, 2018 at 7:08 PM, Senduran <[email protected]> wrote:
>
>> Hi Godwin,
>>
>> As a workaround you can try the following.
>>
>> This happens because of the following property contains null as string
>> value
>> <property name="Id" expression="json-eval($.id)" scope="default"
>> type="STRING"/>
>>
>> So instead of reading the property in the argument, evaluating the JSON
>> path will solve I think
>> i.e
>> <arg evaluator="json" expression="$.id"/>
>>
>> Regards
>> Senduran
>>
>> On Wed, Mar 7, 2018 at 5:13 PM, Godwin Shrimal <[email protected]> wrote:
>>
>>> Hi All,
>>>
>>> If we pass a JSON Payload with a null value, it is considering that null
>>> value as "null" string. Please see a sample API and payload
>>>
>>> API
>>> ====
>>>
>>> <resource methods="POST" uri-template="/testapi">
>>>
>>>       <inSequence>
>>>
>>>          <property name="Id" expression="json-eval($.id)"
>>> scope="default" type="STRING"/>
>>>
>>>          <property name="ContractId" expression="json-eval($.contractid)"
>>> scope="default" type="STRING"/>
>>>
>>>          <property name="DealId" expression="json-eval($.dealid)"
>>> scope="default" type="STRING"/>
>>>
>>>          <payloadFactory media-type="xml">
>>>
>>>             <format>
>>>
>>>                <m1:updateForOperation xmlns:m1="http://www.test.com.";>
>>>
>>>                   <m1:iId>$1</m1:iId>
>>>
>>>                   <m1:iBitrixDealId>$2</m1:iBitrixDealId>
>>>
>>>                   <m1:iBitrixContractId>$3</m1:iBitrixContractId>
>>>
>>>                </m1:egateUpdateForBitrixOperation>
>>>
>>>             </format>
>>>
>>>             <args>
>>>
>>> *               <arg evaluator="xml" expression="get-property('Id')"/>*
>>>
>>>                <arg evaluator="xml" expression="get-property('Deal
>>> Id')"/>
>>>
>>>                <arg evaluator="xml" expression="get-property('Cont
>>> ractId')"/>
>>>
>>>             </args>
>>>
>>>          </payloadFactory>
>>>
>>>          <log level="full"/>
>>>
>>>          <send>
>>>
>>>             <endpoint key="conf:DSEndpoint"/>
>>>
>>>          </send>
>>>
>>>          <respond/>
>>>
>>>       </inSequence>
>>>
>>>       <outSequence>
>>>
>>>          <send/>
>>>
>>>       </outSequence>
>>>
>>>    </resource>
>>>
>>> Payload
>>> ======
>>>
>>> {
>>>
>>>            "id":null,
>>>
>>>            "contractid":"test",
>>>
>>>            "dealid":"test1"
>>>
>>> }
>>>
>>> According to above sample highlight argument passing to dss service as
>>> "null" string. It looks this is a bug.
>>>
>>>
>>> Thanks
>>> Godwin
>>>
>>> --
>>> *Godwin Amila Shrimal*
>>> Associate Technical Lead
>>> WSO2 Inc.; http://wso2.com
>>> lean.enterprise.middleware
>>>
>>> mobile: *+94772264165*
>>> linkedin: *https://www.linkedin.com/in/godwin-amila-2ba26844/
>>> <https://www.linkedin.com/in/godwin-amila-2ba26844/>*
>>> twitter: https://twitter.com/godwinamila
>>> <http://wso2.com/signature>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [email protected]
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> *Madhawa Gunasekara*
> Senior Software Engineer
> WSO2 Inc.; http://wso2.com
> lean.enterprise.middleware
>
> mobile: +94 719411002 <+94+719411002>
> blog: *http://madhawa-gunasekara.blogspot.com
> <http://madhawa-gunasekara.blogspot.com>*
> linkedin: *http://lk.linkedin.com/in/mgunasekara
> <http://lk.linkedin.com/in/mgunasekara>*
>



-- 
*Godwin Amila Shrimal*
Associate Technical Lead
WSO2 Inc.; http://wso2.com
lean.enterprise.middleware

mobile: *+94772264165*
linkedin: *https://www.linkedin.com/in/godwin-amila-2ba26844/
<https://www.linkedin.com/in/godwin-amila-2ba26844/>*
twitter: https://twitter.com/godwinamila
<http://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to