SOAP UI访问REST服务出现500错误的问题

同步发表在:http://www.xeclipse.com/?p=1366

 

创建了一个简单的REST Web Service,使用Java代码访问完全OK,但是用SOAP UI就一直出现500的错误,简单的Google一下,发现了问题。小结一下。

错误的截图:

具体:


   
      
      Error 500 Could not resolve view with name 'employees' in servlet with name 'rest'
   
   
      

HTTP ERROR 500

Problem accessing /service/employees. Reason:

Could not resolve view with name 'employees' in servlet with name 'rest'

Caused by:

javax.servlet.ServletException: Could not resolve view with name 'employees' in servlet with name 'rest'
 

REST的地址为:http://localhost:8082/service/employees, 使用浏览器可以正常访问,显示



	
	Employees


ID Name Email
1 Huang Yi Ming [email protected]
2 Wu Dong Fei [email protected]
 

说明REST 服务OK,使用SOAP UI等工具就有问题了,这里有个东西需要注意:

Accept必须设置,默认为“*/*;”

比如:

当然,如果你的REST服务制定需要某种Accept,就需要设置为其他了:

@RequestMapping(method=RequestMethod.GET, value="/emps", headers="Accept=application/xml, application/json")
	public @ResponseBody EmployeeList getAllEmp() {
 

这里就可以设置为

Accept = application/xml 或者 applicaiton/json

你可能感兴趣的:(Web)