I build a Java Restfull Web Service to be called by ionic apps running on Android Mobil devices.
The code is successfully running on Android 4.4 Mobile
.
but not running on any other android mobile devices with os :android lollipop, marshmallow
.
webservices web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>test</display-name>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<!-- <servlet-class>com.sun.jersey.server.impl.container.servlet.ServletAdaptor</servlet-class> -->
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>test</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Rest webservice code
package test;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@Path("/test")
public class test_Services
{
@POST
@Consumes("application/x-www-form-urlencoded")
@Path("/insertTest")
public String InsertTest(String json)
{
System.out.println("POST JSON>>>>>>>>>>>>>"+json);
return json.toString();
}
}
Rest webservice dependencies
Here is Hybride Application using ionic and angularjs code
$http({
method: 'POST',
url: 'http://mapps.testlab.local:8080/test/test/insertTest',
data: data,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
}).then(function successCallback(res) {
}, function errorCallback(err) {
deferred.reject(res.err);
});
When i debug that using chrome on Android lollipop and marshmallow it gives me the following error:
Failed to load resource: net::ERR_NAME_NOT_RESOLVED
Please help me to fix this issue. I am using JAVA using Eclipse Mars.1