我创建了一个基于ksoap android和jcifs的NTLM认证SOAP客户端。实现如下所示:
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;
}
//....
}
从它的外观来看,ksoap正在生成正确的消息,因为
bufferStream
按预期用SOAP信封填充。jcifs似乎也在做它的工作,我可以看到NTLM挑战响应是通过wireshark进行的。问题是消息正文丢失。它只是空的。因此,Web服务遇到501和
InputStream
返回的为空。
有人知道为什么会这样吗?
注意:我正在删除下面的Content-Length标题,因为
setEntity
显然是想设置这个,但ksoap已经设置了。我只需把它取下来
设置实体
重置它。