1. René Ullrich
  2. PowerBuilder
  3. Wednesday, 5 September 2018 12:43 PM UTC

Hi,

 

I try to use a webservice using .NET engine in PB 2017 R2. The server requires a basic authentication.

My code is:

lsoap_connx = CREATE SoapConnection

lsoap_connx.CreateInstance(lnv_zeitdaten, "ztab_zeitdaten")   // returns 0

lsoap_connx.SetBasicAuthentication ("", ls_username, ls_password)  // returns 0

lnv_zeitdaten.webservicecall

 

The calls fails. The server returns a 401.

Username and Password are Ok.

 

I used Wireshark to log the traffic. Is simple HTTP. I can't find any authentication in the request header!?

What I'm doing wrong?

I also tried to set the domain name in SetBasicAuthentication and also to use setOptions.

The SOAPLog file is empty.

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 6 September 2018 07:06 AM UTC
  2. PowerBuilder
  3. # Permalink

I found the reason: The SetBasicAuthentication call must be before CreateInstance.

 

Comment
There are no comments made yet.
Bruce Armstrong Accepted Answer Pending Moderation
  1. Wednesday, 5 September 2018 14:12 PM UTC
  2. PowerBuilder
  3. # 1

The web service is expecting you to pre-authenticate.  Normally the way Basic Authentication works is that the client sends a request without credentials, the server sends back a request asking for them and only then does the client send the credentials.

When the server is configured to require pre-authentication it won't respond with the request for credentials, it just expects them on the initial request and sends the 401 if they aren't there.  That's what you're seeing.  The client isn't sending them on the initial request because that's not normally how this is done.

Some discussion of it here:  https://weblog.west-wind.com/posts/2010/Feb/18/NET-WebRequestPreAuthenticate-not-quite-what-it-sounds-like

And the solution is largely the same.  Create the Basic Authentication request headers manually and include them on the initial request rather than using the method of the proxy.

Comment
  1. René Ullrich
  2. Thursday, 6 September 2018 05:49 AM UTC
Hi Bruce,



If I understand it right I can't use the service using the proxy?

How can I use it with Powerbuilder?



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.