1. Andres Slachevsky
  2. PowerBuilder
  3. Monday, 10 August 2020 18:07 PM UTC

Hello All,

i need to call the WS located in :
190.104.150.226:8033/MidaSoftware2/MidaSoftare

when we call MidaNovedades in SoapUi we get all the accents.

when we call it from PB we lost the characters we set the same encondigo (UTF-8) this is the code we are using :


/ Novedades MIDA

String    ls_novedad, &

                                                ls_version_n, &

                                                ls_modulo, &

                                                ls_texto, &

                                                ls_pass

Integer li_i

Long                      ll_novedad, &

                                                ll_modulo, &

                                                ll_max_novedad

 

ll_novedad = 1

 

ls_request = 'MidaNovedades'

ls_soap_action = '"' + gs_mida_server + '/MidaSoftware2/MidaSoftware/' + ls_request + '"'

 

                // Armar Request

                ls_xml_request = '<?xml version="1.0" encoding="UTF-8"?>' + &

                '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mid="' + gs_mida_server + '/MidaSoftware2/MidaSoftware">' + &

                '<soapenv:Header/>' + &

                '               <soapenv:Body>' + &

                '                               <mid:'+ls_request+'>' + &

                '                                               <mid:user>xxx</mid:user>' + &

                '                                               <mid:pass>'+ls_pass+'</mid:pass>' + &

                '                                               <mid:novedad>'+ls_novedad+'</mid:novedad>' + &

                '                               </mid:'+ls_request+'>' + &

                '               </soapenv:Body>' + &

                '</soapenv:Envelope>'

               

                // Crear el objeto y asignar sus propiedades

                lo_client = Create httpClient

                lo_client.SetRequestHeader("Content-Type", "text/xml;charset=UTF-8")

                lo_client.SetRequestHeader("SOAPAction", ls_soap_action)

                lo_client.SetRequestHeader("Content-Length", String(len(ls_xml_request) ))

                li_ret = lo_client.sendrequest('POST', ls_url, ls_xml_request )

               

                If li_ret = -1 then

                                li_i = 20

                end if

               

                If li_ret = 1 Then

                                //SE VERIFICA EL STATUS DE LA RESPUESTA

                                li_StatusCode    = lo_client.GetResponseStatusCode()

                                ls_ret                                    = lo_client.GetResponseStatusText()

               

                                If li_Statuscode = 200 Then

                                                //SI ESTA OK SE LEE EL VALOR DE LA RESPUESTA

                                                li_ret                                     = lo_client.getresponsebody(ls_data)

                                                ls_version_n      = f_texto_extraer(ls_data, '<@version>', '</@version>' )

                                                ls_modulo                           = f_texto_extraer(ls_data, '<@modulo>', '</@modulo>' )

                                                ls_texto                                               = f_texto_extraer(ls_data, '<@texto>', '</@texto>' )

                                                ll_max_novedad              = Long(f_texto_extraer(ls_data, '<@max_novedad>', '</@max_novedad>'))

 

                                                If ll_novedad > ll_max_novedad Then

                                                                li_i = 20

                                                Else       

                                                                If ls_version_n = '***' Then

                                                                                li_i = 20

                                                                Else       

                                                                                ll_modulo = Long(ls_modulo)

                                                                                Insert Into admin.mida_novedades (novedad, version, modulo, descripcion) Values (:ll_novedad, :ls_version_n, :ll_modulo, :ls_texto) ;

                                                                End If   

                                                End If   

                                End If   

                                               

                                if li_Statuscode<> 200 then

                                                li_i = 20

                                end if

                               

                End If   

Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 11 August 2020 06:13 AM UTC
  2. PowerBuilder
  3. # 1

Hi Andres,

Could you try modifying your code of the SendRequest method's Syntax like the two examples listed below one by one and see if it works:

objectname.SendRequest ( methodName, urlName, blob data )
objectname.SendRequest ( methodName, urlName, string data, encodingType )

You can also refer to the following link for more details on sending the request from the HTTPClient object to the server and below is the Example 4 from this link:

https://docs.appeon.com/pb2019r2/powerscript_reference/ch10s684.html

//Example 4
//This example sends a blob query when requesting information from a URL using the POST method:
Integer  li_rc
String ls_ReturnJson
HttpClient lnv_HttpClient
lnv_HttpClient = Create HttpClient
Blob lblb_data
lblb_data = Blob('{"empId":101, "fname":" John", "lname": "Guevara"}', EncodingUTF8!)
// Sends request using POST method (to add the string data to the body and set to the Content-Length header)
li_rc = lnv_HttpClient.SendRequest("POST", "http://demo.appeon.com/PB/webapi_client/employee/blob", lblb_data)
// Obtains the response data
if li_rc = 1 and lnv_HttpClient.GetResponseStatusCode() = 200 then
 lnv_HttpClient.GetResponseBody(ls_ReturnJson)
end if

Regards,

 

Comment
There are no comments made yet.
Andres Slachevsky Accepted Answer Pending Moderation
  1. Tuesday, 11 August 2020 13:29 PM UTC
  2. PowerBuilder
  3. # 2

Thanks Mark

but the WS is a Soap WS not a Rest so we need to call it creating the Full request 

Comment
  1. Mark Lee @Appeon
  2. Wednesday, 12 August 2020 02:34 AM UTC
Yes. I understand that. I’m just suggesting that you comment you old code like below, and then try the new syntax to see if it works.

// li_ret = lo_client.sendrequest('POST', ls_url, ls_xml_request )

li_ret = lo_client.sendrequest('POST', ls_url, ls_xml_request , EncodingUTF8!)

or

lb_blob = Blob(ls_xml_request , EncodingUTF8!)

li_ret = lo_client.sendrequest('POST', ls_url, lb_blob )

  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.