KSoap-Android\JCIFS sends empty HTTP post

耗尽温柔 提交于 2019-12-10 14:04:46

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/3843966/ksoap-android-jcifs-sends-empty-http-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!