KSoap-Android\JCIFS sends empty HTTP post
Asked Answered
S

1

5

I created an NTLM authenticating SOAP client based on KSOAP-Android and JCIFS. The implementation looks something like this:

public class NtlmServiceConnection implements ServiceConnection 
{
    public NtlmServiceConnection(final SoapConnectionInfo connectionInfo, String path)      
    {
        httpclient = new DefaultHttpClient();
        httpclient.getAuthSchemes().register(AuthPolicy.NTLM, new NTLMSchemeFactory());

    //...

    @Override
    public InputStream openInputStream() throws IOException {
        ByteArrayEntity re = new ByteArrayEntity(bufferStream.toByteArray());
        post.removeHeaders("CONTENT-LENGTH");
        post.setEntity(re);
        HttpResponse rep = httpclient.execute(post);
        InputStream stream = rep.getEntity().getContent();
        return stream;
    }

    //....
}

From the looks of it KSOAP is generating the correct message because bufferStream is populated with the SOAP envelope as expected. JCIFS seems to be doing its job as well as I can see the NTLM challenge response taking place via Wireshark. The issue is that the message body is missing. It is simply null. Due to this the web service encounters a 501 and the InputStream returned is null.

Anyone have a clue why this would happen?

Note: I'm removing the CONTENT-LENGTH header below because setEntity apparently tries to set this but KSOAP has already set it. I simply remove it and allow setEntity to reset it.

Safekeeping answered 2/10, 2010 at 1:22 Comment(0)
S
1

I finally figured it out and blogged about it here: http://csharpening.net/blog/?p=271

Safekeeping answered 30/11, 2010 at 1:44 Comment(3)
That's all fine and dandy, but once you successfully authenticate, how do you persist that authentication so you can go back to using HttpTransportSE? In other words, I can authenticate and get the SoapObjects for that response, but as soon as I run another AsyncTask that uses HttpTransportSE, I get a "no authentication challenge found."Accomplice
You should post the code in comment instead of linking to your own blog. Your source link from blog doesn't work any longer and should you go take your blog down the wisdome will be lost. To bad I needed this.Irresolute
Been years since I've looked at this and I've been real bad at the blog recently. Actually found the ZIP dl.dropboxusercontent.com/u/3771090/MobileTfsBuildMonitor.zipSafekeeping

© 2022 - 2024 — McMap. All rights reserved.