ramykort / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

Can't make basic authentication to IIS server #78

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Write the code:

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
headers.add(new HeaderProperty("Authorization", "Basic V1M6")); // basic auth 
header with login/pass hash
try {
    Object response = androidHttpTransport.call(SOAP_ACTION, envelope, headers);
} catch (IOException e) {
} catch (XmlPullParserException e) {
}

With "Authorization: Basic V1M6" header connection needs to be authoritative, 
but if I tried to make request to IIS (and IIS only - apache works fine!) it 
reply with "401 Authorization Required". As I can see it makes this reply on 
"authorization" header line with small first letter.
I can't find the code which rule that right now.

Original issue reported on code.google.com by v...@itgorod.ru on 22 Aug 2011 at 5:39

GoogleCodeExporter commented 8 years ago
I dont understand what you mean in the description at all. Can you please 
provide details about your problem.. 

Original comment by mosa...@gmail.com on 23 Aug 2011 at 4:28

GoogleCodeExporter commented 8 years ago
I trying to make a call to the web service which secured by http basic 
authorization and can't do this, because (as I can understand after my 
investigation) HttpURLConnectionImpl, which is uses by ServiceConnectionSE, 
sends custom http headers in small case, but web service expect it with a 
capital first letter.
Now I think that it is not a problem in ksoap2 code itself, but don't 
understand how to change a general behaviour.

P.S. Sorry for a bad English.

Original comment by v...@itgorod.ru on 23 Aug 2011 at 5:56

GoogleCodeExporter commented 8 years ago
I thought the headers are not case sensitive.. if you can point me to a 
reference that says they should initial caps we can change in the library.. 

Original comment by mosa...@gmail.com on 23 Aug 2011 at 5:11

GoogleCodeExporter commented 8 years ago
You absolutely right - by rfc headers is case insensitive. And the web service 
I need to use break the rfc (and I need to use that service - it's a web 
extention for a national wide accounting software :( ). But is it possible to 
use that kind of header that was applyed at creation?
Now the library is changing header's case to all small letters.

Original comment by v...@itgorod.ru on 23 Aug 2011 at 5:44

GoogleCodeExporter commented 8 years ago
Sorry.. I dont understand what you are asking now?

Original comment by mosa...@gmail.com on 23 Aug 2011 at 5:50

GoogleCodeExporter commented 8 years ago
If you look at the code I wrote on the first post, you could see that I used:

headers.add(new HeaderProperty("Authorization", "Basic V1M6"));

Header name "Authorization" is begin with capital "A". But the server received 
"authorization" - with small initial letter. I find it on 
androidHttpTransport.connection.connection.reqHeaders and then confirm it with 
mod_dumpio on apache. So is it possible to use the form was used at header 
creation time?

Original comment by v...@itgorod.ru on 23 Aug 2011 at 6:08

GoogleCodeExporter commented 8 years ago
I assume that somewhere in doing the creation of the http request it changes 
the case. I have no idea where though. You can debug into the library and see 
where it does it and we can maybe introduce a parameter that does not change 
the case or something along these lines.. 

Original comment by mosa...@gmail.com on 23 Aug 2011 at 6:45

GoogleCodeExporter commented 8 years ago
More deeper investigation showed me that the problem is in the core libs 
(HttpURLConnection and/or around here) and exists on Android version 2.2 (and, 
may be, older versions) only. 2.3 have no that problem, it sends headers in 
needed form (and also works with Authenticator class for VM-level 
authentication that prevent from using workaround methods like used in the 
first post). So, I think, this issue can be safely closed.

Thank you very much for the patience and for your work!

Original comment by v...@itgorod.ru on 25 Aug 2011 at 5:18

GoogleCodeExporter commented 8 years ago
No problem

Original comment by mosa...@gmail.com on 25 Aug 2011 at 5:52