---
title: "SOAP UI访问REST服务出现500错误的问题"
author: "salever"
date: "2012-10-10T12:01:27Z"
tags: []
categories: ["互联网"]
slug: "soap-ui-rest-500"
draft: false
lastmod: "2012-10-10T12:03:10Z"
id: 1694988
url: "https://salever.iteye.com/blog/1694988"
---

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

 

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

![](http://www.xeclipse.com/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif "更多...")

错误的截图：

[![](http://www.xeclipse.com/wp-content/uploads/2012/10/tmp1.jpg "tmp1")](http://www.xeclipse.com/wp-content/uploads/2012/10/tmp1.jpg) 具体：

```
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
      <title>Error 500 Could not resolve view with name 'employees' in servlet with name 'rest'</title>
   </head>
   <body>
      <h2>HTTP ERROR 500</h2>
      <p>
         Problem accessing /service/employees. Reason:
         <pre>Could not resolve view with name 'employees' in servlet with name 'rest'</pre>
      </p>
      <h3>Caused by:</h3>
      <pre>javax.servlet.ServletException: Could not resolve view with name 'employees' in servlet with name 'rest'
```

 

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

```
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Employees</title>
</head>
<body>
<table border=1>
	<thead><tr>
		<th>ID</th>
		<th>Name</th>
		<th>Email</th>
	</tr></thead>

	<tr>
		<td>1</td>
		<td>Huang Yi Ming</td>
		<td>huangyim@cn.ibm.com</td>
	</tr>

	<tr>
		<td>2</td>
		<td>Wu Dong Fei</td>
		<td>wudongf@cn.ibm.com</td>
	</tr>

</table>
</body>
</html>
```

 

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

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

比如：

[![](http://www.xeclipse.com/wp-content/uploads/2012/10/tmp2.jpg "tmp2")](http://www.xeclipse.com/wp-content/uploads/2012/10/tmp2.jpg) 当然，如果你的REST服务制定需要某种Accept，就需要设置为其他了：

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

 

这里就可以设置为

Accept = application/xml 或者 applicaiton/json