System.Web.Services.Protocols.SoapException:服务器无法处理请求.---> System.Data.SqlClient.SqlException:

问题描述 投票:1回答:1

我有一个Android应用程序,我想从SqlServer 2008中检索数据。

android应用程序连接到访问Sqlserver数据库的Web服务,我尝试调用从数据库中检索数据的方法“getCommentsTest”,我收到此错误:

System.Web.Services.Protocols.SoapException:服务器无法处理请求.---> System.Data.SqlClient.SqlException:无法打开登录请求的数据库“我的数据库”。登录失败。登录失败,来自用户'NT AUTHORITY \ NETWORK SERVICE'。

知道我在发布后试图在浏览器上查看Web服务,我调用了该函数并且它工作正常。

这是调用Web服务的android代码:

public void callTestGetComments(){try {

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GET_COMMENTS);

       request.addProperty("eID", 140);




        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet=true;
        envelope.setOutputSoapObject(request);

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL_TEST);
        androidHttpTransport.call(SOAP_ACTION_GET_COMMENTS, envelope);

        Object result = (Object)envelope.getResponse();

        String xml=result.toString();
        Document doc=XMLfromString(xml);

        doc.getDocumentElement().normalize();

        //System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
        NodeList nList = doc.getElementsByTagName("Comment");
        //System.out.println("-----------------------");
                //String commentBody,userName;
                String commentBody="";

        for (int i = 0; i < nList.getLength(); i++) 
        {

           Node nNode = nList.item(i);
           if (nNode.getNodeType() == Node.ELEMENT_NODE) 
           {

              Element eElement = (Element) nNode;
                      //Comment c=new Comment();
             commentBody += getTagValue("comment", eElement);
              commentBody+= getTagValue("uPhone", eElement);
                  //System.out.println("Nick Name : " + getTagValue("nickname", eElement));
              //System.out.println("Salary : " + getTagValue("salary", eElement));
                      //comments.add(c);
           }
       // tv.setText(result.toString());
           tv.setText(commentBody);
        } 
    }
    catch (Exception e) {
        tv.setText(e.getMessage());
        }
}
android web-services sql-server-2008
1个回答
0
投票

这是与权限相关的问题。当您在浏览器中查看Web服务时,是否要求您登录?

你用什么方法与网络服务交谈?你可以发布该代码吗?我愿意打赌你没有通过任何凭证,但我不能确定没有看到代码。

你有权访问SQL服务器吗?如果是这样,您检查错误日志是否有无效登录?

基于这个SO question,没有简单的方法来使用来自Android的NTLM对Windows服务进行身份验证。

它们在sql服务器上的用户并不重要,因为从Android设备的角度来看,它们未经过身份验证。

© www.soinside.com 2019 - 2024. All rights reserved.