I am using Jquery ajax to call java webservice its getting connected fine but with parameters value as null.
JQUERY :
var obj = { hname: $("#txtRuleName").val(), hdates: $("#txtRuleDates").val(), hremark: $("#txtRuleRemark").val(), isDelete: false, created_date: 'CURRENT_TIMESTAMP', updated_date: 'CURRENT_TIMESTAMP' };
$.ajax({
type: "GET",
contentType: "application/json",
dataType: "jsonp",
//crossOrigin: true,
url: "http://localhost:portnumber/PostGresTestDB/rest/db/insert",
jsonpCallback: 'jsonCallback',
data: JSON.stringify(obj)
});`
JAVA WEBSERIVE FUNCTION :
@Path("/db")
public class DBOperaions {
@GET
@Path("/insert")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public String InsertDBData(@PathParam("hname") String hname,
@PathParam("hdates") String hdates,
@PathParam("hremark") String hremark,
@PathParam("isDelete") boolean isDelete,
@PathParam("created_date") String created_date,
@PathParam("updated_date") String updated_date) {
//DB Dumping Code
}
WEBBROWSER CONSOL :
http://localhost:portnumber/PostGresTestDB/rest/db/insert?callback=jsonCallback&{%22hname%22:%22sdfsfd%22,%22hdates%22:%2205/05/2015,%2005/06/2015,%2005/07/2015,%2005/08/2015,%2005/09/2015,%2005/10/2015,%2005/11/2015,%2005/12/2015,%2005/13/2015,%2005/14/2015,%2005/15/2015,%2005/16/2015%22,%22hremark%22:%22fdfsdfsfd%22,%22isDelete%22:false,%22created_date%22:%22CURRENT_TIMESTAMP%22,%22updated_date%22:%22CURRENT_TIMESTAMP%22}&_=1423111725889
But in webservice paramets values are
hname =null
hdates = null
hremark =null
isDelete = false // as this is boolean feild
created_date=null
updated_date = null
because of this, service fills all null data to table.
Can anybody tells me why this is happening?