2 Replies - 2996 Views - Last Post: 21 June 2018 - 02:29 AM

#1 ganeshcr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-June 18

servicemessage empty response

Posted 20 June 2018 - 12:45 AM

my servicemessage code :
 public class Transform {
   
public TermResponse SuccessResponse(Term term) {
	TermResponse tr = new TermResponse();
	ServiceMessage serviceMessage = new ServiceMessage();
	serviceMessage.setCode("200");
	serviceMessage.setType("success");
	serviceMessage.setDescription("created successfully");

	tr.setMessage(serviceMessage);
	tr.setTermResponse(term);
	
	return tr;
	
}
}  


my controller code:
 @RequestMapping(path="/term/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity <TermResponse> addTerm (@RequestBody TermBean bean) {
		TermResponse st = new TermResponse();
		
        
		try {
			termService.addTerm(bean);	
			termResponse = termTransformation.SuccessResponse(Term term);
			 httpStatus = HttpStatus.OK;
			 
	       return new ResponseEntity<TermResponse>(httpStatus);
	       }
	       catch(Exception ex) {
	       }
		return null;
	       }


response code:
 package com.toverto.edu.term;

import java.io.Serializable;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.toverto.edu.student.ServiceMessage;

@JsonPropertyOrder({"message"})

public class TermResponse implements Serializable{
	@JsonProperty("message")
	private ServiceMessage message;
	public ServiceMessage getMessage() {
		return message;
		}

		public void setMessage(com.toverto.edu.term.ServiceMessage serviceMessage) {
		
			
		}

		public void setTermResponse(Term term) {
			
			
		}
		}


		


please any one help me that Im getting a blank response
the response must be {
"message":{
"type": "success",
"code": 200,
"description": "created successfully"
}
}

Is This A Good Question/Topic? 0
  • +

Replies To: servicemessage empty response

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6823
  • View blog
  • Posts: 28,274
  • Joined: 12-December 12

Re: servicemessage empty response

Posted 20 June 2018 - 04:33 AM

In your controller you are catching any exception, but doing nothing with it. You ignore exceptions and the information they provide. This is a very poor practice and won't help you to fix problems.

In the handler output the exception details, or remove it entirely and just let whatever happens happen.

Also do not use a meaningless title like "java programming". I have changed it for you.
Was This Post Helpful? 0
  • +
  • -

#3 ganeshcr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-June 18

Re: servicemessage empty response

Posted 21 June 2018 - 02:29 AM

ok,In transform.java class if i want to add it for create,update,delete methods so how to change in the description.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1