TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ravi Gaddam
NA
42
13.6k
Need java Client Example for Spring Rest Service
Sep 17 2018 4:00 AM
Hi Folks ,
Could you please help me to write Java client for Spring Rest Service but am seeing issues like Http Status 400(Bad request) , 500(Internal Server) Errors. I will give my sample template code below .Please advise any changes are required in service and client applications.
Service :
------------
@RequestMapping(value = "/employeeAccessRequest", method = RequestMethod.GET)
public @ResponseBody EmployeeAccessResponse getEmployeeAccess(@RequestBody EmployeeAccessRequest employeeAccessRequest) {
EmployeeAccessResponse employeeAccessResponse =null;
--------------------------------------
------------------------------------
return employeeAccessResponse ;
Client:
---------
/* GET */
private static EmployeeAccessResponse getEmployeeAccess(String xml){
System.out.println("Testing getEmployeeSecureAccess API----------");
ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(HttpClients.createDefault());
RestTemplate restTemplate = new RestTemplate(requestFactory);
List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
acceptableMediaTypes.add(MediaType.APPLICATION_XML);
acceptableMediaTypes.add(MediaType.APPLICATION_JSON);
HttpHeaders headers = new HttpHeaders();
headers.setAccept(acceptableMediaTypes);
headers.setContentType(MediaType.APPLICATION_XML);
HttpEntity<String> request = new HttpEntity<String>(xml, headers);
final EmployeeAccessResponse employeeAccessResponse = restTemplate.postForObject(REST_SERVICE_URI+"/employeeAccessRequest",request, EmployeeAccessResponse.class);
System.out.println(employeeAccessResponse);
return employeeAccessResponse;
}
Thnaks
Ravi Gaddam
Reply
Answers (
0
)
Can Excel do ad b2c authentication?
soap web services