Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KSoap-Android\JCIFS sends empty HTTP post

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.

like image 693
Adam Driscoll Avatar asked Nov 14 '22 07:11

Adam Driscoll


1 Answers

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

like image 175
Adam Driscoll Avatar answered Dec 06 '22 07:12

Adam Driscoll