Call Rest Service Using Authen In PowerBuilder

Call Rest Service Using Authen In PowerBuilder . Using input json data and response json data type.

Good Luck!

Was this article helpful?

Related Articles

0 0 votes
Article Rating
Subscribe
Notify of
guest
9 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Richard
Richard
2 years ago

Buen día, una consulta
Donde obtiene el dato esta variable ls_response_text …?

If IsNull(ls_response_text) Then
ls_response_text = “”
End If

En mi aplicación tengo error en esta linea
loo_xmlhttp.status=200

Error accessing external object property responsetext at line 79 

que podria ser

richard
richard
2 years ago
Reply to  PassWords

line 79 = If http.status=200 Then

Error Error accessing external object property responsetext at line 79

richard
richard
2 years ago
Reply to  PassWords

ok, check if isavlid(loo_xmlhttp) then.

thanks.

———————————————
Here my code
is something wrong?
———————————————-
Error accessing external object property responsetext
If http.status=200 Then
ls_respuesta = http.responseText 

———————————————————————-
Try
OLEObject http
http = Create OLEObject

li_create = http.ConnectToNewObject(“MSXML2.ServerXMLHTTP”)
If li_create <> 0 Then
li_create = http.ConnectToNewObject( “Msxml2.XMLHTTP.3.0”)
End If
If(li_create <> 0 ) then
ls_respuesta = “Msxml2 Component initialization failed!”

End if
boolean lb_result
OleObject dom
long result

dom = Create OleObject
result = dom.ConnectToNewObject(“Msxml2.DOMDocument.3.0″)
lb_result = dom.LoadXML (ls_xml)
IF lb_result = false THEN
destroy (dom)
END IF

ll_length = Len(ls_xml)
String sSoapAction
as_approve=”;
http.Open(“POST”,gs_urlws,True)
http.setRequestHeader(“Content-Type”,”text/xml;charset=UTF-8″)
http.setRequestHeader(“Content-Length”,String(ll_length))

http.setRequestHeader (“SOAPAction”,”http://tempuri.org/SendCPE”)
http.setTimeouts(5000,6000,10000,10000)

http.Send(dom.xml)
Do While http.readyState <> 4
Yield()
SetRedraw(true)
If http.readyState<> 4 Then
  
w=w + 1
If w > 10000 then 
If isvalid(w_envio_fecredito_xml) Then close(w_envio_fecredito_xml)
exit 
End If
End If
Loop

If http.status=200 Then
ls_respuesta = http.responseText 
else
ls_respuesta = “”
End If

dom.DisconnectObject()
http.DisconnectObject()
Destroy (dom)
Destroy (http)
Catch(Exception ex)
ls_xml=””;
ls_respuesta = “RuntimeErrorExp: “+ex.GetMessage() +’-Invoca ws: ‘+string(ex.text)
FileClose (li_fichero)
If IsValid (http) then Destroy http;
If IsValid (dom) then Destroy dom; 
Catch (RuntimeError err)

ls_xml=””;
ls_respuesta = “RuntimeError: “+err.GetMessage() +’-Invoca ws: ‘+string(err.text)

FileClose (li_fichero)
If IsValid (http) then Destroy http; //Destroy http
If IsValid (dom) then Destroy dom; //Destroy http
End Try

richard
richard
2 years ago
Reply to  PassWords

Thank you
i tell you

R P
11 months ago

Hello,
is there a way to get bearer authentication using that example of code? Tried it with no luck. I have PB 10.2
I would very much appreciate a response

R P
11 months ago

Hello,
is there a way to implement bearer authentication with this code?
I have tried it with no luck. I’m using PB 10.2.
Any help appreciated
Thank you