1. Olaf Bönning
  2. PowerBuilder
  3. Monday, 6 May 2024 09:49 AM UTC

We are switching from SOAP to REST and I am asking myself which implementation/class is the best: HttpClient or RestClient? Which one should i choose and why?

I started with RestClient but run into difficulties loading a file (octet-stream) into PowerBuilder.
The following works fine as long as the request returns a string into ls_json. It works fine with text files. But when the request returns a PDF file or similar it fails.
    inv_restclient.SendGetRequest(ls_url, ls_json)

I found out that HttpClient offers the possibility to return a blob which works perfectly:
    BLOB lbl_filecontent
    lhc_HttpClient.SendRequest("GET", ls_url)
    lhc_HttpClient.GetResponseBody(lbl_filecontent)

With other words: so far HttpClient is my first choice.

Which way have you choosed? And why?

Kind regards!
Olaf

Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 8 May 2024 17:30 PM UTC
  2. PowerBuilder
  3. # 1

The HTTPClient is a generic all-purpose so it can do anything but requires more coding than RESTClient.  So yes, if you are not concerned about a bit of extra coding you could always use the HTTPClient. 

As Chris mentioned, the most common use case for RESTClient is if you created a Web service with the .NET DataStore.  For any Web service not using .NET DataStore or third-party Web services, HTTPClient might be your best bet.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 7 May 2024 14:45 PM UTC
  2. PowerBuilder
  3. # 2

Hi Olaf;

  The RestClient object is designed to handle simple data types in a 2D format (row & column). Any more requirements to handle more complex nested data, 3D or Blob datum would be best via HTTPClient which is much more flexible.  HTH

Regards .. Chris

Comment
  1. Chris Pollach @Appeon
  2. Wednesday, 8 May 2024 12:38 PM UTC
Hi Olaf;

It's forte is really designed to work best with RestFul Web services like ones built with SnapDevelop. In Snap, you're probably using the .Net DataWindow. So now you probably need to transfer the .Net DW buffer over to a PB C/S DW. This is where the RestClient class shines for performing either direct DW to DW transfers.

Regards ... Chris
  1. Helpful 1
  1. Roland Smith
  2. Wednesday, 8 May 2024 17:01 PM UTC
What is the usual data format for Snap web services? JSON?
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Wednesday, 8 May 2024 17:27 PM UTC
Yes, JSON. The point is if you use .NET DataStore in the Web service then the data coming back is what a client-side DataWindow is expecting. The RESTClient directly pipes that into the DataWindow control.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.