Forum Discussion

breaux's avatar
breaux
Contributor
9 years ago

REST Basic Authentication error at endpoint level

Version 5.2.1 on Windows

 

When I add my HTTP Basic Authentication to individual REST requests, it works fine with my service.

 

When I add the same username and password to my endpoint definition instead, I get an apache.httpclient.ClientProtocolException.

 

Here are the log excerpts (with host names obscured). Note the original project endpoint was localhost:9080 (without authentication required), and the new one with it required is what I'm showing as real-endpoint-server.

 

From SoapUI log:

 

Tue Dec 01 18:35:44 CST 2015:DEBUG:Loading Definition...
Tue Dec 01 18:35:44 CST 2015:INFO:Loading schema types from [http://localhost:9080.wadl]
Tue Dec 01 18:35:44 CST 2015:INFO:Getting schema http://localhost:9080.wadl
Tue Dec 01 18:35:44 CST 2015:DEBUG:Loaded Definition: ok
Tue Dec 01 18:36:12 CST 2015:DEBUG:Attempt 1 to execute request
Tue Dec 01 18:36:12 CST 2015:DEBUG:Sending request: GET /rbm/vehicle/my-item-number?vin=my-vin HTTP/1.1
Tue Dec 01 18:36:12 CST 2015:DEBUG:Receiving response: HTTP/1.1 401 Not authorized.  Authentication required for protected file.
Tue Dec 01 18:36:12 CST 2015:DEBUG:Connection can be kept alive indefinitely
Tue Dec 01 18:36:12 CST 2015:DEBUG:Target requested authentication
Tue Dec 01 18:36:12 CST 2015:DEBUG:Authorization challenge processed
Tue Dec 01 18:36:12 CST 2015:DEBUG:Authentication scope: BASIC 'Renew_by_Mail'@real-endpoint-server:443
Tue Dec 01 18:36:12 CST 2015:INFO:real-endpoint-server:443 requires authentication with the realm 'Renew_by_Mail'
Tue Dec 01 18:36:12 CST 2015:DEBUG:Found credentials
Tue Dec 01 18:36:12 CST 2015:DEBUG:Attempt 2 to execute request
Tue Dec 01 18:36:12 CST 2015:DEBUG:Sending request: GET /rbm/vehicle/my-item-number?vin=my-vin HTTP/1.1
Tue Dec 01 18:36:18 CST 2015:DEBUG:Connection closed
Tue Dec 01 18:36:18 CST 2015:DEBUG:Connection shut down
Tue Dec 01 18:36:18 CST 2015:ERROR:Exception in request: org.apache.http.client.ClientProtocolException
Tue Dec 01 18:36:18 CST 2015:ERROR:An error occurred [org.apache.http.client.ClientProtocolException], see error log for details
Tue Dec 01 18:36:18 CST 2015:INFO:Error getting response for [http://localhost:9080.vehicle:06975686]; org.apache.http.client.ClientProtocolException

 

From error log:

 

Tue Dec 01 18:36:18 CST 2015:ERROR:org.apache.http.client.ClientProtocolException
   org.apache.http.client.ClientProtocolException
       at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:822)
       at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
       at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$Helper.execute(HttpClientSupport.java:233)
       at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport.execute(HttpClientSupport.java:323)
       at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.submitRequest(HttpClientRequestTransport.java:290)
       at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:220)
       at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:119)
       at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
       at java.util.concurrent.FutureTask.run(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)
   Caused by: org.apache.http.ProtocolException: The server failed to respond with a valid HTTP response
       at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:109)
       at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:252)
       at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:281)
       at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:247)
       at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
       at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$SoapUIHttpRequestExecutor.doReceiveResponse(HttpClientSupport.java:147)
       at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
       at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:633)
       at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:454)
       at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
       ... 11 more

 

However, in http log, it does appear that a reasonable-looking reply was returned, along with a 200 response code. Which also matches my server's http log.

  • Anyone? Should basic auth at the endpoint level propagate down to the resources, methods, requests?

    • nmrao's avatar
      nmrao
      Champion Level 3
      Unsure of the question. Would you please show the problem with screen shots or small video to reproduce it?
      • breaux's avatar
        breaux
        Contributor

        If I set user/password here, at the endpoint level:

         

        It is not passed in the request underneath that. I have to manually then add it to the request itself:

        This is a lot of duplicated work and makes me think I'm doing something incorrect.