Topic
12 replies Latest Post - ‏2013-10-08T15:24:27Z by swlinn
Nimish_Mehta
Nimish_Mehta
6 Posts
ACCEPTED ANSWER

Pinned topic first character getting truncated in JSON message on datapower XI50 v 6.0

‏2013-10-04T07:16:24Z |

While sending JSON messages from SOAPUI/cURL to datapower XI50 on firmware v6.0 the opening braces { on the JSON message are getting truncated.

If we add an additional brace "{{" in the starting of the message, it works fine. Our service also supports the same flow in XML which is working fine.

What can be the possible causes/solution to this issue ?

  • HermannSW
    HermannSW
    3145 Posts
    ACCEPTED ANSWER

    Re: first character getting truncated in JSON message on datapower XI50 v 6.0

    ‏2013-10-04T07:56:48Z  in response to Nimish_Mehta

    Hi,

    I have never seen any problems like this, do you use "--data-binary" option of curl?

    Can you attach a small sample failinginput here?

    And tell the firmware version and servive type?

    Do you use JSON request type or Non-XML with convert-http(JSON)?


    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

    • Nimish_Mehta
      Nimish_Mehta
      6 Posts
      ACCEPTED ANSWER

      Re: first character getting truncated in JSON message on datapower XI50 v 6.0

      ‏2013-10-04T08:46:41Z  in response to HermannSW

      Hi

      Yes i am using --data-binary option for curl.

      The service is a MPGW. I am on firmware v XI50.6.0.0.2nn. The request type is set to JSON.

      The request is failing at match action itself with Invalid JSON format .

      if i send {"Key":"Value"} i get "Key":"Value"}..  in the probe.

      and if i send {{"Key":"Value"} i get {"Key":"Value"} in the probe.

      • HermannSW
        HermannSW
        3145 Posts
        ACCEPTED ANSWER

        Re: first character getting truncated in JSON message on datapower XI50 v 6.0

        ‏2013-10-04T10:26:37Z  in response to Nimish_Mehta

        Hi,

        I did install XI50.6.0.0.2nn on dp3-l3 box and see no problem, did you quote your input string?

        Find attached MPGW service export from dp3-l3 for your testing:

        $ curl --data-binary '{"Key":"Value"}' http://dp3-l3:2498 ; echo
        <?xml version="1.0" encoding="UTF-8"?>
        <json:object xsi:schemaLocation="http://www.datapower.com/schemas/json jsonx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx">
        <json:string name="Key">Value</json:string></json:object>
        $


        Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

        Attachments

        • Nimish_Mehta
          Nimish_Mehta
          6 Posts
          ACCEPTED ANSWER

          Re: first character getting truncated in JSON message on datapower XI50 v 6.0

          ‏2013-10-07T06:04:52Z  in response to HermannSW

          Hi,

          I tried the mpgw provided by you. It is working as expected.

          However the same config is not working for me. I am using two processing rules. one uses XPath to match xml.

          The second rule uses application/json in http header to match json. It is here the request fails with invalid json content. If i remove the xml rule ,set the match action to * in url and remove all the actions in the processing rule the request is recieved without the truncated braces.

          I am still unable to get JSON to work with my configuration.

          Regards,

          Nimish

          • HermannSW
            HermannSW
            3145 Posts
            ACCEPTED ANSWER

            Re: first character getting truncated in JSON message on datapower XI50 v 6.0

            ‏2013-10-07T06:20:23Z  in response to Nimish_Mehta

            Hi Nimish,

            can you please attach a sample service export demonstrating the problem?
             

            Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

             

            • HermannSW
              HermannSW
              3145 Posts
              ACCEPTED ANSWER

              Re: first character getting truncated in JSON message on datapower XI50 v 6.0

              ‏2013-10-07T06:41:56Z  in response to HermannSW

              Hi Nimish,

              your instructions were good enough.

              I ddi create a XPath match action rule with "false()" XPath expression as 1st rule.
              As you described any character prefixing the JSON text is needed.

              Please create a PMR, provide your export, state your use case and refer to this thread.


              Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

               

               

              Updated on 2013-10-07T06:42:27Z at 2013-10-07T06:42:27Z by HermannSW
      • swlinn
        swlinn
        1330 Posts
        ACCEPTED ANSWER

        Re: first character getting truncated in JSON message on datapower XI50 v 6.0

        ‏2013-10-04T16:53:58Z  in response to Nimish_Mehta

        Do you have any processing rules that would be checked (eg, matching rule) prior to the rule you wish to run for this traffic?  If so, what is the matching rule type?

        Regards,
        Steve

        • Nimish_Mehta
          Nimish_Mehta
          6 Posts
          ACCEPTED ANSWER

          Re: first character getting truncated in JSON message on datapower XI50 v 6.0

          ‏2013-10-07T06:06:12Z  in response to swlinn

          Hi,

          I am using application/json in match action to check for json content.

          Regards,

          Nimish

          • swlinn
            swlinn
            1330 Posts
            ACCEPTED ANSWER

            Re: first character getting truncated in JSON message on datapower XI50 v 6.0

            ‏2013-10-07T15:00:51Z  in response to Nimish_Mehta

            Hi Nimish,

            So earlier in the thread indicated you were looking for an xpath match first.  If you pass non-XML in this case, the xpath match will certainly fail, but in the process of making that determination, some of the non-XML data may be consumed and not available for a subsequent match.  If your subsequent match is looking at the Content-Type header being application/json, then move that rule above the xpath match.  Being able to do content type matching of XML vs Non-XML in the manner you describe may be an enhancement request already on the books, but I'd suggest you open a new one to make sure.

            Regards,

            Steve

            • HermannSW
              HermannSW
              3145 Posts
              ACCEPTED ANSWER

              Re: first character getting truncated in JSON message on datapower XI50 v 6.0

              ‏2013-10-07T15:07:01Z  in response to swlinn

              Steve,

              the PMR is needed.

              Even if XPath action does not make sense to use on Non-XML input, it is a bug that it strips the first character.
              This will fail JSON parsing, and I will have to fix that (when getting a PMR).

              Btw, "true()" and "false()" are valid XPath expressions working with Non-XML request type.


              Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

            • Nimish_Mehta
              Nimish_Mehta
              6 Posts
              ACCEPTED ANSWER

              Re: first character getting truncated in JSON message on datapower XI50 v 6.0

              ‏2013-10-08T06:44:01Z  in response to swlinn

              Steve,

              Thanks. It is working as expected now.

              Regards,

              Nimish

              • swlinn
                swlinn
                1330 Posts
                ACCEPTED ANSWER

                Re: first character getting truncated in JSON message on datapower XI50 v 6.0

                ‏2013-10-08T15:24:27Z  in response to Nimish_Mehta

                Hi Nimish,

                Glad it is working!! I'd still encourage you to open the PMR in the case where the rules are reversed.

                Best Regards,
                Steve