当前位置:网站首页>The WebService interface writes and publishes calls to the WebService interface (I)
The WebService interface writes and publishes calls to the WebService interface (I)
2022-04-23 05:01:00 【Chen junyang】
Write and publish webService Interface
1. To write webService Interface
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService(name = "Login",// Port name
serviceName = "testService", // WebService The service name
targetNamespace = "http://webService.test.com" // Namespace , The default is inverted package name
)
public interface TestService {
// Provide an open service
@WebMethod(operationName = "loginPass")
// Change the method name
String loginPass(@WebParam(name = "userId") String userId,@WebParam(name = "password") String password);
}
2. Write interface implementation classes
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
/** 1. Implementation class */
@WebService(endpointInterface = "com.thinkgem.jeesite.common.webService.MyService",// Interface path
name = "Login",// Port name
serviceName = "testService", // WebService The service name
targetNamespace = "http://webService.test.com" // Namespace , The default is inverted package name ( If code is generated when calling , be com.test.webService Package path for code )
)
public class TestServiceImpl implements TestService {
@WebMethod(operationName = "loginPass" // Change the method name
)
@Override
public String loginPass(
@WebParam(name = "userId") String userId,
@WebParam(name = "password") String password) {
if ("admin".equals(userId) && "123".equals(password)) {
return "success";
}
return "error";
}
}
3. Release webService Interface services
import javax.xml.ws.Endpoint;
public class TestPublisher {
public static void main(String[] args) {
// Designated Services url
String url = "http://localhost:8089/testservice";
// Specify the service implementation class
TestService server = new TestServiceImpl();
// Use the command line publisher Endpoint Publishing services
Endpoint.publish(url, server);
}
}
4. Look at the test webService Whether the interface service is published successfully
Set when the browser accesses the publication url + ?wsdl, Such as :http://localhost:8089/testservice?wsdl
If it shows :
5. webService Interface call
see webService The interface is written and published with webService Interface call ( Two )
版权声明
本文为[Chen junyang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220552495027.html
边栏推荐
- QPushButton slot function is triggered multiple times
- 直播带货表格模板-自动显示图片-自动关联系列商品
- PHP 统计指定文件夹下文件的数量
- Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data
- 深度学习笔记 —— 数据增广
- PHP counts the number of files in the specified folder
- [winui3] write an imitation Explorer file manager
- List remove an element
- Mac 进入mysql终端命令
- Innovation training (XII) reptile
猜你喜欢
多线程基本概念(并发与并行、线程与进程)和入门案例
Use the built-in function of win to transfer files between two computers in the same LAN (the speed is the same as that between local disks)
【数据库】MySQL多表查询(一)
Learning Android II from scratch - activity
The 2021 more reading report was released, and the book consumption potential of post-95 and Post-00 rose
2022/4/22
Cross border e-commerce | Facebook and instagram: which social media is more suitable for you?
Detailed explanation of the differences between TCP and UDP
Perfect test of coil in wireless charging system with LCR meter
Details related to fingerprint payment
随机推荐
List remove an element
Sword finger offer: symmetric binary tree (recursive iteration leetcode 101)
vscode ipynb文件没有代码高亮和代码补全解决方法
JS détermine si la chaîne de nombres contient des caractères
Day.js 常用方法
A trinomial expression that causes a null pointer
MySQL 慢查询
和谐宿舍(线性dp / 区间dp)
机器学习---线性回归
Learning Android V from scratch - UI
Field injection is not recommended using @ Autowired
scp命令详解
Wechat payment function
Learning Android II from scratch - activity
HRegionServer的详解
[2022 ICLR] Pyramid: low complexity pyramid attention for long range spatiotemporal sequence modeling and prediction
POI export message list (including pictures)
【数据库】MySQL单表查询
C. Tree Infection(模拟+贪心)
Getprop property