1. Waine Abreu
  2. PowerBuilder
  3. Monday, 8 May 2023 12:26 PM UTC

Hi everyone,

 

I'm having trouble migrate SOAP to REST.

 

We have some PB Soap WS.

We are migrating to PB 22 and we need to use REST.

Its not getting info of our website to datawindow. I'm a bit lost because i made connection of database in json file, but i'm not there is something else or if it's not making authentication on ourwebsite. 

PB22 code.

lnv_restclient = CREATE RESTClient
lnv_restclient.SetClientCert( 'login', 'password')
lnv_restclient.Setrequestheaders("Content-Type:application/json;charset=UTF-8~r~nAccept-Encoding:gzip")
ll_rc = lnv_restclient.Retrieve (dw_aplication , 'http://webapps...')

 

Accepted Answer
Andreas Mykonios Accepted Answer Pending Moderation
  1. Monday, 8 May 2023 12:56 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi.

Can you try to change:

lnv_restclient.Setrequestheaders("Content-Type:application/json;charset=UTF-8~r~nAccept-Encoding:gzip")

to:

lnv_restclient.SetRequestHeader("Content-Type", "application/json;charset=UTF-8")
lnv_restclient.SetRequestHeader("Accept-Encoding", "gzip")

Just to test. Otherwise the syntax you provided seems ok.

What error does retrieve returns?

Andreas.

Comment
  1. Waine Abreu
  2. Tuesday, 9 May 2023 17:04 PM UTC
ok, I'm reviewing other parts of code and making a change and see with all alteration make it work and get the data of website
  1. Helpful
  1. Waine Abreu
  2. Tuesday, 9 May 2023 17:52 PM UTC
in my doubt above I asked about creating an instance, above datasheet is a proxyname and lnv_webservice is proxy object, do i need to provide that in restclient ? if yes how since i make the instance on code like you replied.

conn = create SoapConnection

datasheet lnv_webservice

Ex: ll_rc = conn.createinstance(lnv_webservice, 'datasheet')



thanks
  1. Helpful
  1. Andreas Mykonios
  2. Thursday, 11 May 2023 12:59 PM UTC
First of all, the proxy object cannot be used with httpclient and restclient. As I said I would try to do the request with restclient and see what is the response. If it isn't working I would try to switch to httpclient and see if I can use this object to consume the web service. Is your webservice created with an old version of powerbuilder?

Andreas.
  1. Helpful
There are no comments made yet.
Waine Abreu Accepted Answer Pending Moderation
  1. Thursday, 11 May 2023 12:52 PM UTC
  2. PowerBuilder
  3. # 1

Thanks for the help of all, I noticed webservice was a SOAP webservice.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 9 May 2023 20:14 PM UTC
  2. PowerBuilder
  3. # 2
Comment
  1. Waine Abreu
  2. Wednesday, 10 May 2023 11:48 AM UTC
Hi Chris,



I'm using PB22, this article of soap, would it work in PB22?

Since we are migrating our system to 2022, i saw its only working REST api
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 10 May 2023 18:50 PM UTC
Yes, it's basically the ONLY way you can do SOAP => REST in any newer PB versions.

The RestClient alternative only works when you have a pure 2D (basically a DBMS like result set - Rows + columns only - JSON structure being returned by the Restful web service). HTH
  1. Helpful
There are no comments made yet.
Waine Abreu Accepted Answer Pending Moderation
  1. Tuesday, 9 May 2023 18:20 PM UTC
  2. PowerBuilder
  3. # 3

Just as complement and share some visual code. I'm sending how it was originally working 

A proxy was imported to the workspace with many attribute to use. datasheetdataservice is ourwebservice

Its created an instance and attribute, which I need "entrada" as entrance in xml and "resposta" as return to datawindow 

dataconnectiondstrequest entrada[]
dataconnectionsapresponse resposta[]

entrada[1] = create dataconnectiondstrequest
resposta[1] = create dataconnectionsapresponse

and code as 

datasheetdataservice lnv_webservice
SoapConnection conn

conn = create SoapConnection
conn.setbasicauthentication( 'confab', 'login', '*****')
ll_rc = conn.CreateInstance (lnv_webservice, 'datasheetdataservice')

 

And then after getting info from entrada

has a connection with one of attribute imported from datasheetdataservice webservice.

I'm having trouble to do that on REST, even I do instance, it only return -1, what do i need to change? How i use REST in this occasion

 

Thanks

Attachments (1)
Comment
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.