I have an android application in which i want to retrieve data from SqlServer 2008.
The android application connects to a web service that accesses the Sqlserver database, I tried calling the method "getCommentsTest" that retrieves data from the database and I got this error:
System.Web.Services.Protocols.SoapException: Server was unable to process request.---> System.Data.SqlClient.SqlException: Cannot open database "my database" requested by the login. The login failed. Login failed from user 'NT AUTHORITY\NETWORK SERVICE.'
Knowing that I tried to view the web service on the browser after publishing it, I called the function and it worked.
And here's the android code to call the web Service:
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());
}
}