I'm doing a tiny code to get if it can connect or not to a database. I have several codes like this working, but I don't know why I can't figure out why is this not working.
The exception is the following:
10-24 06:09:08.362: E/Exception:(1753): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG (empty) <br>@1:7 in java.io.InputStreamReader@4176d928)
Java code:
private final String NAMESPACE = "http://10.0.0.47/fullexample/server.php/";
private final String URL = "http://10.0.0.47/fullexample/server.php";
/*
....
*/
private class get_connectivity extends AsyncTask<String, Integer, String> {
@Override
protected String doInBackground(String... params) {
try{
SoapObject request = new SoapObject(NAMESPACE, "can_connect");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(URL + "/can_connect", envelope);
return "done";
}catch (Exception e){
Log.e("Exception:", e.toString());
}
return "not done";
}
@Override
protected void onPostExecute(String result) {
// got_connection = it's a global string variable
got_connection = result;
}
}
And the function can_connect (in PHP webservice) is just the following:
function can_connect(){
$host = "localhost";
$user = "root";
$database = "fullexampleDB";
$pwd = "";
$db = new mysqli($host, $user, $pwd, $database);
if ($db->connect_errno) {
return false;
exit();
}
$db->close();
return true;
}
I'm always receiving the message "not done" as well. Thanks.