Android System.Web.Services.Protocols.SoapException:服务器无法处理请求。-->;System.Data.SqlClient.SqlException:
我有一个android应用程序,我想在其中从SQLServer2008检索数据 android应用程序连接到访问Sqlserver数据库的web服务, 我尝试调用从数据库检索数据的方法“getCommentsTest”,但出现以下错误: System.Web.Services.Protocols.SoapException:服务器无法处理 请求。-->System.Data.SqlClient.SqlException:无法打开数据库“我的数据库” 由登录请求。登录失败。从用户“NT授权\网络服务”登录失败 我知道在发布web服务后,我试图在浏览器上查看它,于是调用了该函数,它成功了 下面是调用web服务的android代码: public void callTestGetComments() { 尝试 {Android System.Web.Services.Protocols.SoapException:服务器无法处理请求。-->;System.Data.SqlClient.SqlException:,android,web-services,sql-server-2008,Android,Web Services,Sql Server 2008,我有一个android应用程序,我想在其中从SQLServer2008检索数据 android应用程序连接到访问Sqlserver数据库的web服务, 我尝试调用从数据库检索数据的方法“getCommentsTest”,但出现以下错误: System.Web.Services.Protocols.SoapException:服务器无法处理 请求。-->System.Data.SqlClient.SqlException:无法打开数据库“我的数据库” 由登录请求。登录失败。从用户“NT授权\网络服
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());
}
}
SoapObject请求=新的SoapObject(名称空间、方法名称、获取注释);
请求添加属性(“eID”,140);
SoapSerializationEnvelope=新的SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(请求);
HttpTransportSE androidHttpTransport=新的HttpTransportSE(URL_测试);
调用(SOAP\u ACTION\u GET\u COMMENTS,信封);
对象结果=(对象)envelope.getResponse();
字符串xml=result.toString();
Document doc=XMLfromString(xml);
doc.getDocumentElement().normalize();
//System.out.println(“根元素:+doc.getDocumentElement().getNodeName());
NodeList nList=doc.getElementsByTagName(“注释”);
//System.out.println(“--------------------------”;
//字符串体,用户名;
字符串body=“”;
对于(int i=0;i
这是一个与权限相关的问题。当您在浏览器中查看web服务时,它是否要求您登录
您使用什么方法与Web服务交谈?你能把那个密码贴出来吗。我愿意打赌你不会通过任何证书,但如果没有看到代码,我无法确定
您有权访问SQL server吗?如果是,您是否检查了错误日志中的无效登录
基于此,使用android上的NTLM对windows服务进行身份验证并不容易
不管他们的用户在sql server上是什么,因为从android设备的角度来看,他们没有经过身份验证。首先,浏览器没有要求我登录,因为我们将其调整为使用windows身份验证登录,下面是我们的连接字符串:“数据源=;初始目录=爬虫;集成安全=真;”我将把调用web服务的android代码放在问题中。web服务使用用户“NT AUTHORITY\NETWORK service”访问数据库,该用户是sqlServer中的系统管理员