webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Corrupted data when convert byte to string

    Posted Tue June 04, 2024 07:50 AM

    Currently I’m making a calling HTTP service as a client and data was corrupted when covert byte to string in webmethod 10.15.
    For some reason, when I get a 200 response from Host, there’s no any problem.(well converted), data corruption have only with 400 response.(in postman, response is well converted.)
    Please check is there any problems or not.


    #webMethods


  • 2.  RE: Corrupted data when convert byte to string

    Posted Tue June 04, 2024 08:44 AM

    Hi,

    looks like there is a missing map step between the invocations of pub.client:http and byteToString.
    Please add the proper screen shots.

    Regards,
    Holger


    #webMethods


  • 3.  RE: Corrupted data when convert byte to string



  • 4.  RE: Corrupted data when convert byte to string

    Posted Tue June 04, 2024 04:31 PM

    Try without passing encoding in both http step and bytesToString steps


    #webMethods


  • 5.  RE: Corrupted data when convert byte to string

    Posted Wed June 05, 2024 12:00 AM

    I tried like a below, but still fail to convert when get 400 error


    #webMethods


  • 6.  RE: Corrupted data when convert byte to string

    Posted Wed June 05, 2024 10:03 AM

    Try these options

    1. If Target API has swagger file, then create REST API descriptor (RAD consumer) and test using connectors if it is giving same response for 400 vs 200/404.

    2. Compare response headers coming to postman when request is 400 vs 404 /200, check if there are any differences in content-type or encoding.


    #webMethods


  • 7.  RE: Corrupted data when convert byte to string

    Posted Wed June 05, 2024 02:48 PM

    My guess is the response is gzip’d (or compressed with other Content-Encoding directive). Clients like Postman will automatically decompress such responses without you needing to do anything explicit.

    You can check this by viewing the headers that are returned. If you share a screen shot of variables returned in the header output, we can confirm that is what is happening.

    In the request you can send the Accept-Encoding: identity to tell the server to not encode the response. But this is not always honored. We had a case where an API always compressed regardless of what we sent in Accept-Encoding. And did so only for error responses whereas 2xx responses were always clear text.

    You can create your own general purpose http service that adds capability such as this to the built-in pub.client:http .

    The steps are not checking the HTTP response – but should.

    Side note: I have never seen a case where the claim is “data is corrupted” that the data is actually corrupted. Invariably, it is due to incorrect character endoding (e.g. using ASCII for parsing UTF-8 byte) or to compression. The rule of thumb is if you see binary data when you expect to see text, the most likely culprit is incorrect assumptions/information about what the byte stream represents.


    #webMethods