Ошибка при использовании веб-служб Sharepoint с Android

#android #web-services #sharepoint #ntlm

#Android #веб-службы #sharepoint #ntlm

Вопрос:

Я пытаюсь использовать веб-сервис Sharepoint authentication.asmx с Android, используя следующий код:

 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);
  

Здесь se — это StringEntity, содержащий soap-конверт, но я получаю следующий ответ:-

 <?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. ---amp;> Site is not configured for Claims Forms Authentication.</faultstring>
      <detail />
    </soap:Fault>
  </soap:Body>
</soap:Envelope>
  

Комментарии:

1. Я предлагаю вам использовать библиотеку Ksoap

2. получение 401 несанкционированной ошибки