1. Laurent CRUMIERE
  2. PowerBuilder
  3. Monday, 15 May 2023 08:22 AM UTC

Hi,

 

I'm using a soap connection to use a webservice in PB 2021 and it works fine.

I'm trying to migrate to rest connection and get an unexpected error.

I used Postman to validate my Post arguments 

 

Postman Headers :

Body :

When I test the request, I get an answer :

 

 

In PB 2021, I'm trying to use HTTPclient object like that :

 

string ls_body, ls_url, ls_ret, ls_data
httpClient lnv_HttpClient
long l_statut_reponse
integer li_rc, li_ret


ls_body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">'+ " ~n" + &
' <soapenv:Header />'+ " ~n" + &
' <soapenv:Body>'+ " ~n" + &
' <tem:GetLogin>'+ " ~n" + &
' <tem:pLogin>borne</tem:pLogin>'+ " ~n" + &
' <tem:pPassword>bornearakis1</tem:pPassword>'+ " ~n" + &
' </tem:GetLogin>'+ " ~n" + &
' </soapenv:Body>'+ " ~n" + &
'</soapenv:Envelope>"'

ls_url = "https://portail-clients.val-solutions.fr/UegarPRESOA_EXTServer/Bornes.svc"

lnv_HttpClient = Create httpClient

// Header
lnv_HttpClient.SetRequestHeader("Content-Type", "text/xml")
lnv_HttpClient.SetRequestHeader("SoapAction", "http://tempuri.org/IBornesService/GetLogin")
lnv_HttpClient.SetRequestHeader("Host", "portail-clients.val-solutions.fr")
lnv_HttpClient.SetRequestHeader("Accept", "*/*")
lnv_HttpClient.SetRequestHeader("Accept-Encoding", "gzip, deflate, br")
lnv_HttpClient.SetRequestHeader("Connection", "keep-alive")

// Post Command

li_rc = lnv_HttpClient.sendRequest("Post", ls_url, ls_body)
// => received 1

l_statut_reponse = lnv_HttpClient.GetResponseStatusCode()
// => received 500

ls_ret = lnv_HttpClient.GetResponseStatusText()
// => received "Internal Server Error"

li_ret = lnv_HttpClient.GetResponseBody(ls_data)

 

I don't understand why !

Thanks in advance for your help !

 

 

 

 

 

 

Daryl Foster Accepted Answer Pending Moderation
  1. Wednesday, 17 May 2023 07:15 AM UTC
  2. PowerBuilder
  3. # 1

Hi Laurent,

It's always a bit messy to create xml with string concatenation, did you validate the xml your code generated? e.g. stepping through with the debugger and getting the value of ls_body and putting that in an xml validator?

One obvious error is that you have a trailing double quote after the /soapenv element which doesn't match up with an opening quote and isn't valid xml.

 

'</soapenv:Envelope>"'

 

I'd probably delete that double quote as a first step and see if that fixes your problem.

 

Comment
  1. Laurent CRUMIERE
  2. Wednesday, 17 May 2023 07:34 AM UTC
Hi Daryl,

Thanks you for your help !

The double quote was effectively the probelm.

Regards
  1. Helpful
  1. Daryl Foster
  2. Wednesday, 17 May 2023 23:39 PM UTC
No worries, glad I could help
  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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.