为简单的 REST Web 服务调整 SoapUI
Adjusting SoapUI for simple REST web service
我的 Eclipse IDE
.
中有 REST
基于 Jersey
的 Web 服务在 TomCat 9
上运行
使用 broser 测试时服务器运行正常:
开业linkhttp://localhost:8080/messenger/webapi/messages
带来:
<messages>
<message>
<author>koukushik</author>
<created>2019-02-20T12:48:41.817+02:00</created>
<id>1</id>
<message>Hello World</message>
</message>
<message>
<author>koukushik</author>
<created>2019-02-20T12:48:41.817+02:00</created>
<id>2</id>
<message>Hello Jersey</message>
</message>
</messages>
我正在尝试在 SoapUI 4.5.1 中做同样的事情:
我愿意:
New SoapUI project:
project name: "pro1"
New REST Service
Service name: "serv1"
Service endpoint: http://localhost:8080/messenger/webapi/messages
New REST Resource
Name resource1
Resource Path/Endpoint http://localhost:8080/messenger/webapi/messages
New REST Method
Method_1
GET
请求 RAW:
GET http://localhost:8080/messenger/webapi/messages/messenger/webapi/messages HTTP/1.1
Accept-Encoding: gzip,deflate
Host: localhost:8080
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
回答HTML:
<html lang="en">
<head>
<meta content="HTML Tidy for Java (vers. 26 Sep 2004), see www.w3.org" name="generator"/>
<title>HTTP Status 404 Not Found</title>
<style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style>
</head>
<body>
<h1>HTTP Status 404 Not Found</h1>
<hr class="line"/>
<p>
<b>Type</b>
Status Report
</p>
<p>
<b>Message</b>
Not Found
</p>
<p>
<b>Description</b>
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
</p>
<hr class="line"/>
<h3>Apache Tomcat/9.0.14</h3>
</body>
</html>
看起来 GET 方法末尾包含 HTTP/1.1
。那是问题吗?如何使 SoapUI
与我的项目一起工作?
UPD
现在工作正常:
问题是您在 RAW 请求中看到的 URL 不是您想要的 returns 404 状态码
请尝试以下设置
我的 Eclipse IDE
.
REST
基于 Jersey
的 Web 服务在 TomCat 9
上运行
使用 broser 测试时服务器运行正常:
开业linkhttp://localhost:8080/messenger/webapi/messages
带来:
<messages>
<message>
<author>koukushik</author>
<created>2019-02-20T12:48:41.817+02:00</created>
<id>1</id>
<message>Hello World</message>
</message>
<message>
<author>koukushik</author>
<created>2019-02-20T12:48:41.817+02:00</created>
<id>2</id>
<message>Hello Jersey</message>
</message>
</messages>
我正在尝试在 SoapUI 4.5.1 中做同样的事情:
我愿意:
New SoapUI project:
project name: "pro1"
New REST Service
Service name: "serv1"
Service endpoint: http://localhost:8080/messenger/webapi/messages
New REST Resource
Name resource1
Resource Path/Endpoint http://localhost:8080/messenger/webapi/messages
New REST Method
Method_1
GET
请求 RAW:
GET http://localhost:8080/messenger/webapi/messages/messenger/webapi/messages HTTP/1.1
Accept-Encoding: gzip,deflate
Host: localhost:8080
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
回答HTML:
<html lang="en">
<head>
<meta content="HTML Tidy for Java (vers. 26 Sep 2004), see www.w3.org" name="generator"/>
<title>HTTP Status 404 Not Found</title>
<style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style>
</head>
<body>
<h1>HTTP Status 404 Not Found</h1>
<hr class="line"/>
<p>
<b>Type</b>
Status Report
</p>
<p>
<b>Message</b>
Not Found
</p>
<p>
<b>Description</b>
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
</p>
<hr class="line"/>
<h3>Apache Tomcat/9.0.14</h3>
</body>
</html>
看起来 GET 方法末尾包含 HTTP/1.1
。那是问题吗?如何使 SoapUI
与我的项目一起工作?
UPD
现在工作正常:
问题是您在 RAW 请求中看到的 URL 不是您想要的 returns 404 状态码
请尝试以下设置