java - jaxrs - Unable to call the webservice : 404 Not Found Error -
i have created simple webservice unable call it. 404 not found error.
package com.fms.mdw.rest; @path("/search") public class searchwebservice { @post @path("/searchdata") @consumes(mediatype.application_json) @produces("application/json") public fmsresponseinfo getsearchdata(searchdto searchdto) { system.out.println("entered getsearchdata()"); fmsresponseinfo fmsresponseinfo = new fmsresponseinfo(); list<searchdetailsdto> searchdetailsdtolist = new arraylist<>(); (int = 0; < 5; i++) { searchdetailsdto searchdetailsdto = new searchdetailsdto(); searchdetailsdto.setbarcode("barcode" + i); searchdetailsdto.setdocno("docno" + i); searchdetailsdto.setdoctype("doctype" + i); searchdetailsdtolist.add(searchdetailsdto); } fmsresponseinfo.setstatus("200"); fmsresponseinfo.setmessage("success"); fmsresponseinfo.setdata(searchdetailsdtolist); system.out.println("leaving getsearchdata()"); return fmsresponseinfo; } }
searchdto has 2 fields searchtype, searchtext both of type string.so json payload {"searchtype":"", "searchtext":""}
i have registered webservice in following manner in web.xml :
<?xml version="1.0" encoding="utf-8"?> <web-app id="webapp_id" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <display-name>latestfms</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <servlet> <servlet-name>latestfms web application</servlet-name> <servlet-class>org.glassfish.jersey.servlet.servletcontainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>com.fms.mdw.rest</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>latestfms web application</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> </web-app>
i able access webpages, unable call webservice. using restclient send post request. web server apache tomcat 7 , jersey 2.16 .
the url hitting http://localhost:8082/latestfms/rest/search/searchdata.
i unable resolve issue, please ! ! !
Comments
Post a Comment