当前位置:网站首页>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
边栏推荐
- vscode ipynb文件没有代码高亮和代码补全解决方法
- MySQL uses or to query SQL, and SQL execution is very slow
- Mac enters MySQL terminal command
- List< Map> Replication: light copy and deep copy
- MySQL - index
- Field injection is not recommended using @ Autowired
- Day. JS common methods
- MySQL time function query
- Analysis of POM files
- 【数据库】MySQL基本操作(基操~)
猜你喜欢
AQS源码阅读
深度学习笔记 —— 数据增广
Deep learning notes - semantic segmentation and data sets
Pixel 5 5g unlocking tutorial (including unlocking BL, installing edxposed and root)
[winui3] Écrivez une copie du gestionnaire de fichiers Explorer
Introduction to raspberry pie 3B - system installation
MySQL memo (for your own query)
深度学习笔记 —— 语义分割和数据集
Innovation training (IV) preliminary preparation - server
[2022 ICLR] Pyramid: low complexity pyramid attention for long range spatiotemporal sequence modeling and prediction
随机推荐
Painless upgrade of pixel series
Getprop property
DIY 一个 Excel 版的子网计算器
深度学习笔记 —— 微调
List< Map> Replication: light copy and deep copy
Innovation training (XI) airline ticket crawling company information
The 2021 more reading report was released, and the book consumption potential of post-95 and Post-00 rose
Introduction to raspberry pie 3B - system installation
mysql5. 7. X data authorization leads to 1141
【数据库】MySQL多表查询(一)
Luogu p2731 horse riding fence repair
AQS源码阅读
What are the redis data types
解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].
静态流水线和动态流水线的区别认识
C list field sorting contains numbers and characters
多线程基本概念(并发与并行、线程与进程)和入门案例
MySQL - index
Informatics Olympiad 1955: [11noip popularization group] Swiss round | openjudge 4.1 4363: Swiss round | Luogu p1309 [noip2011 popularization group] Swiss round
2022/4/22