1. Ricardo Colarina
  2. PowerBuilder
  3. Thursday, 1 February 2018 05:55 AM UTC

Hi All,

Can someone please give an example on how to set the username and password when calling a webservice?  Can this be done with the new RESTClient object and how?

Thanks.

Best Regards,

Ricardo

Bruce Armstrong Accepted Answer Pending Moderation
  1. Saturday, 3 February 2018 21:50 PM UTC
  2. PowerBuilder
  3. # 1

I'm confused by your question.

The WS-Security you mention in the question subject is a SOAP service standard.  REST is an entirely different web services protocol.  The two don't mix and match.

It's also above and beyond Basic Authentication, which is what the body of your question seems to be about.

Exactly what kind of a web service are you trying to call and how exactly are you expected to pass username and password to it?

 

Comment
  1. Ricardo Colarina
  2. Sunday, 4 February 2018 21:37 PM UTC
Hi Bruce,



Without getting into too much detail, the webservice function I'm trying to call is offered over a soap interface.  A user can log in to the provider's website and generate a comprehensive report.  The provider gave me a copy of the wsdl so that we can integrate the report into our PB application.  So I created a webservice proxy, but there is no function in their webservice to pass the userid and password.  I tried using MS XMLHTTP COM component to perform the HTTP POST instead and passing the XML request with the security header and I'm able to call the function successfully then just parsed the XML response.  However, I'm not getting all the data I'm expecting to get in the response, judging by the structure generated by the webservice proxy when I tried using soap and the report generated when done directly in the provider's website.  So I was wondering with PB2017 R2, if there's a way now of using soap to pass the user credentials before invoking the webservice function, or if there's another way of doing this.



Thanks.



Best Regards,



Ricardo

  1. Helpful
There are no comments made yet.
Christian Freund Accepted Answer Pending Moderation
  1. Thursday, 1 February 2018 11:56 AM UTC
  2. PowerBuilder
  3. # 2

Hi,

 

the question is what authentication you use.

If it is Basic authentication you can add it as an authentication header.

inv_httpclient.ClearRequestHeaders()
inv_httpclient.SetRequestHeader("Accept", "application/json")
inv_httpclient.SetRequestHeader("Accept-Language", "de,en-US;q=0.7,en;q=0.3")
inv_httpclient.SetRequestHeader("Authorization", 'Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
inv_httpclient.SetRequestHeader("Host", "localhost")
ll_rc = inv_httpclient.sendrequest( "GET","")
ll_statuscode = inv_httpclient.GetResponseStatusCode()
if ll_rc = 1 and ll_statuscode = 200 then
     inv_httpclient.GetResponseBody(ls_string)

...

you have to replace xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with username:password as a Base64 coded string

 

Regrads, Christian

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Thursday, 1 February 2018 10:43 AM UTC
  2. PowerBuilder
  3. # 3

For the REST Client feature of PB 2017 R2 we are adding support for OAuth2 in PB 2017 R3, which is scheduled to release on July 31, 2018.  This is our recommended approach, but maybe others can chime in with a interim workaround.

Comment
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Thursday, 1 February 2018 09:05 AM UTC
  2. PowerBuilder
  3. # 4

Hi Ricardo,

you can check this video

http://www.powerbuildertv.com/index.php/en/component/content/article/9-recording/722

for setting authentication properties when calling SOAP WS.

For RESTClient, it was released yesterday, I still have to check the available authentication mechanisms, I will certainly do asap.

Cheers,

.m

Comment
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.