[英]Writing a Rest API inside soap web service
我有一個肥皂網絡服務,目前運行良好。
我需要編寫一個 REST API,它將在內部調用肥皂服務。
任何人都可以建議,如何實現這一目標。
在 Soap 服務里面,我寫了一個restcontroller
代碼是這樣的
@RestController
public class MyController {
@RequestMapping(value = "/restCheck", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<MyResponse<RestCheckResponse>> restCheck(HttpServletRequest request) {
..................
..................
System.out.print("Inside the service...");
....................
return new ResponseEntity<>(MyResponse, org.springframework.http.HttpStatus.OK);
}
}
但是當我在運行服務器后嘗試從郵遞員那里點擊/restCheck
。
我被重定向到肥皂服務給出結果的位置。
Response is something like this on postman.
<html>
<head>
<title>
Web Services
</title>
</head>
<body>
<h1>Web Services</h1>
<table width='100%' border='1'>
<tr>
<td>
Endpoint
</td>
<td>
Information
</td>
</tr>
<tr>
<td>
<table border="0">
<tr>
<td>Service Name:</td>
<td>{http://impl.service.abc.com/}AbcServiceImpl</td>
</tr>
<tr>
<td>Port Name:</td>
<td>{http://impl.service.abc.paytm.com/}AbcServiceImplPort</td>
</tr>
</table>
</td>
<td>
<table border="0">
<tr>
<td>Address:</td>
<td>http://127.0.0.1:80/abc/services</td>
</tr>
<tr>
<td>WSDL:</td>
<td>
<a href="http://127.0.0.1:80/abc/services?wsdl">http://127.0.0.1:80/abc/services?wsdl</a>
</td>
</tr>
<tr>
<td>Implementation class:</td>
<td>com.abc.xyz.service.impl.AbcServiceImpl</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
我在郵遞員上找到的http://localhost:8080/abc/services/restCheck
是http://localhost:8080/abc/services/restCheck
。
注意:當我嘗試在 Eclipse 中以調試模式運行該服務並在函數的第一行添加一個打印語句時,它沒有打印該行,而是顯示[Fatal Error] :1:1: Premature end of file.
注意:我在郵遞員上打的網址是http://localhost:8080/abc/services/restCheck
。 它給出了上述響應。 當我用任何其他隨機字母替換/restCheck
時。 它產生相同的結果。 所以,基本上我的理解是它沒有點擊那個網址。 它基本上是發布soap web 服務。
無法理解我缺少什么。
您正在從 REST Service Wrapper 獲取 WSDL 頁面,這是完全正確的。 你需要在你的 restCheck() 方法中做的是形成一個 HTTP 請求來調用 SOAP 端點,從該端點獲取響應並將其發送回來。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.