从Android使用Sharepoint Web服务时出错

时间:2014-07-06 08:28:36

标签: android web-services sharepoint ntlm

我正在尝试使用以下代码从Android使用Sharepoint authentication.asmx webservice:

String SOAPRequestXML = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
        + "   xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
        + "<soap:Body>"
        + "<Login xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">"
        + "<username>u</username>"
        + "<password>p</password>"
        + "</Login>"
        + "</soap:Body>" + "</soap:Envelope>";
 Log.i("request is ", SOAPRequestXML + "!!!"); 
se = new StringEntity(SOAPRequestXML, HTTP.UTF_8);
se.setContentType("text/xml; charset=utf-8");



HttpPost httppost = new HttpPost(url);
httppost.setEntity(se);
DefaultHttpClient httpclient = new DefaultHttpClient();
// register ntlm auth scheme
httpclient.getAuthSchemes().register("ntlm",
        new NTLMSchemeFactory());
httpclient.getCredentialsProvider()
        .setCredentials(
                // Limit the credentials only to the specified
                // domain and port
                new AuthScope("IPADD", -1),
                // Specify credentials, most of the time only
                // user/pass is needed
                new NTCredentials("myusername", "mypassword", "",
                        ""));

BasicHttpResponse httpResponse = (BasicHttpResponse) httpclient
        .execute(httppost);
HttpEntity resEntity = httpResponse.getEntity();

strResponse = EntityUtils.toString(resEntity);

这里是包含soap信封的StringEntity,但我得到以下响应: -

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>Server was unable to process request. ---&gt; Site is not configured for Claims Forms Authentication.</faultstring>
      <detail />
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

0 个答案:

没有答案