views:

35

answers:

0

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.