1. gili galili
  2. PowerBuilder
  3. Wednesday, 9 October 2024 10:02 AM UTC

Hello,

We are upgrading from PB19 --> PB2022.

I understand that we have to rewrite all code that uses Soup Connection to HTTP Client.

 

Can somebody, Please provide some examples.

Regards,

Marina

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 9 October 2024 12:27 PM UTC
  2. PowerBuilder
  3. # 1
Comment
There are no comments made yet.
gili galili Accepted Answer Pending Moderation
  1. Thursday, 10 October 2024 12:52 PM UTC
  2. PowerBuilder
  3. # 2

Question:

For example (old code VS new code)

//SoapConnection lsp_Cnn -- old code
HttpClient lsp_Cnn -- new code

customersupd p_customersupd  -- (customersupd - WS)

//lsp_Cnn = Create SoapConnection -- old code
lsp_Cnn = Create HttpClient -- new code


//lsp_Cnn.SetProxyServerOptions (ls_location) -- old code
li_rc = lsp_Cnn.SendRequest("GET", ls_location) -- new code - connects to the URL location

//ll_Ret = lsp_cnn.CreateInstance( p_customersupd, "customersupd") -- old code
//ll_Ret = lsp_cnn.GetContextService (  "customersupd" , p_customersupd ) -- tried this' but p_customersupd remains NULL -- what is the new code for this?

 

//luo_wsresult = p_customersupd.updatecustomer( auo_customerschema)  -- old code - calls specific function updatecustomer of customersupd - WS

-- what is the new code for this?

 

Thanks in advance

Marina

Comment
There are no comments made yet.
gili galili Accepted Answer Pending Moderation
  1. Thursday, 10 October 2024 13:51 PM UTC
  2. PowerBuilder
  3. # 3

if I write it like this , I get li_statusCode = 500.  what is incorrect?

 

lsp_Cnn = Create HttpClient

lsp_Cnn.SetRequestHeader("Content-Type", "text/xml")

ls_body = '<?xml version="1.0" encoding="utf-8"?>' + &
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' + &
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' + &
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' + &
'<soap:Body>' + &
'<updatecustomer xmlns="http://tempuri.org/">' + &
'</updatecustomer>' + &
'</soap:Body>' + &
'</soap:Envelope>'

li_rc = lsp_Cnn.SendRequest("POST", ls_location, ls_body)
li_statusCode = lsp_Cnn.GetResponseStatusCode()
li_rc = lsp_Cnn.GetResponseBody(ls_response)

If li_statusCode = 200 Then

    MessageBox("Success", ls_response)
Else

    MessageBox("Error", "HTTP Status Code: " + String(li_statusCode))
End If

 

 

 

Comment
  1. Logan Liu @Appeon
  2. Friday, 11 October 2024 03:26 AM UTC
Hi Marina,

HTTP 500 error is usually an error from the Server side. Refer to: (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500)

After getting the HTTP 500 error, what can you see in "ls_response"? You can also use Fiddler to capture this HTTP request and analyze the HTTP response.

There is an HTTP 500 error case mentioned in https://community.appeon.com/index.php/articles-blogs/tutorials-articles/2-powerbuilder/236-call-soap-web-services-using-httpclient-object (Search "For example, we use Postman to verify it here."). It's caused by the wrong Content-Type. You can verify it.

You can use Fiddler to compare the HTTP requests between your original soap case and the new HttpClient case.

Regards, Logan
  1. Helpful
There are no comments made yet.
gili galili Accepted Answer Pending Moderation
  1. Friday, 11 October 2024 06:59 AM UTC
  2. PowerBuilder
  3. # 4

Hi,

I fixed The 500 issue and moved to Error 400.

Do I understand correctly?:

I need to create an XML string (ls_body) with a reference to updatecustomer function (that inside customersupd  WS).

Also, I need to provide the parameter that updatecustomer function gets.

This is the old code: luo_wsresult = p_customersupd.updatecustomer( auo_customerschema)  

 

But in a new code I have to change parameter auo_customerschema into XML structure?

This is a complicated parameter (auo_customerschema) that includes arrays, strings, numbers.... 

Is there some function that can change it to XML structure?

Do I need to write an XML with complicated structure of parameters for every case that I need to rewrite because of the upgrade?

 

And what about the value that updatecustomer function returns (luo_wsresult)?

 

Thanks,

Marina

 

 

Comment
  1. David Peace (Powersoft)
  2. Friday, 11 October 2024 15:12 PM UTC
Hi Marina

Sadly the answer to your question is no there is no function/tool to convert the complex XML for you. You will have to prepare this XML yourself. Likewise you will need to parse the XML received too. It's a real PIA, pbdom is so clunky to use but dies work.



I feel your pain.



All the best

David
  1. Helpful 1
  1. gili galili
  2. Saturday, 12 October 2024 07:10 AM UTC
Thanks David ;-(
  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.