1. Moshe Tangi
  2. PowerBuilder
  3. Wednesday, 23 October 2019 17:39 PM UTC

hello all

 

I am using the httpclient object to consume a soap ws .

the vendor told me I need to apply a user name before I calling the ws.

How do I do that ?

using the SetRequestHeader function ? something like SetReqesutHeader( "user name", "my user name") ?

But ,  how do I know the what to send as the first parameter to the function ? "user-name" , UserName ...

Doe's the vendor should provide that ?

 

Thanks

 

Moshe

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 23 October 2019 19:34 PM UTC
  2. PowerBuilder
  3. # 1

Hi Moshe;

   The code would be something like the following ...

String  ls_header = "Basic "

String  ls_id = "User:Password"

Blob    lblb_id

lblb_id =  Blob (ls_id )

CoderObject   lo_coder

lo_coder  =   CREATE  CoderObject

ls_id = String (lo_coder.Base64Encode ( lblb_id),  EncodingUTF8! )

ls_header += ls_id

http.SetRequestHeader("Authorization", ls_header)

HTH

Regards ... Chris

Comment
  1. Moshe Tangi
  2. Thursday, 14 November 2019 07:52 AM UTC
Hi Chris ,

What is CoderObject

I tried the code and the app got error on that line

Thanks
  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 14 November 2019 16:38 PM UTC
Hi Moshe;

Its a new object class added to PB2017 (and higher) that allows your PB App's to Encode & Decode datum. Have a look in the PB2017R3 Help file under the same name for more details.

Note: This new class is not yet supported by PowerServer 2019.

Regards ... Chris
  1. Helpful
  1. Moshe Tangi
  2. Monday, 18 November 2019 12:45 PM UTC
Hi Chris

That is my code :

if IsValid(lnv_HttpClient ) then

Try



lo_coder = CREATE CoderObject



ls_header = "Basic "



ls_id = G_user_name + ":" + G_user_password

Messagebox("ls_id=",ls_id)

lblb_id = Blob (ls_id , EncodingANSI!)

ls_id = String (lo_coder.Base64Encode ( lblb_id) )



ls_header += ls_id



Messagebox("ls_header=", ls_header)

lnv_HttpClient.SetRequestHeader("Authorization", ls_header)





Is_HttpToSend = "http://...... "





ls_json = ''

ret = lnv_HttpClient.SendRequest("POST", Is_HttpToSend, ls_json)

Messagebox("lnv_HttpClient.GetResponseStatusCode()=",lnv_HttpClient.GetResponseStatustext())



and I still getting error 401 - UnAuthorized ….

is something missing ?

When I print the var Is_header on screen its after decoding so I see something else from what the server is about to get



Thanks

  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.