当前位置:网站首页>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
边栏推荐
- Graduation project
- 《2021多多阅读报告》发布,95后、00后图书消费潜力攀升
- TypeError: ‘Collection‘ object is not callable. If you meant to call the ......
- Mac enters MySQL terminal command
- 泰克示波器DPO3054自校准SPC失败维修
- ApplicationContext injection bean
- Learning Android II from scratch - activity
- [database] MySQL basic operation (basic operation ~)
- 深度学习笔记 —— 数据增广
- MySQL slow query
猜你喜欢

A trinomial expression that causes a null pointer

DIY is an excel version of subnet calculator

独立站运营 | FaceBook营销神器——聊天机器人ManyChat

Cross border e-commerce | Facebook and instagram: which social media is more suitable for you?

Deep learning notes - object detection and dataset + anchor box

多线程基本概念(并发与并行、线程与进程)和入门案例

Details related to fingerprint payment

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)

深度学习笔记 —— 数据增广

Define defines constants and macros, pointers and structures
随机推荐
Detailed explanation of the differences between TCP and UDP
Day. JS common methods
Deep learning notes - semantic segmentation and data sets
Cross border e-commerce | Facebook and instagram: which social media is more suitable for you?
MySQL -- execution process and principle of a statement
C# List字段排序含有数字和字符
MySQL memo (for your own query)
List remove an element
深度学习笔记 —— 物体检测和数据集 + 锚框
Teach you how to build the ruoyi system by Tencent cloud
Pixel 5 5g unlocking tutorial (including unlocking BL, installing edxposed and root)
Acid of MySQL transaction
Leetcode -- heuristic search
洛谷P2731骑马修栅栏
Basic concepts of multithreading (concurrency and parallelism, threads and processes) and entry cases
Deep learning notes - data expansion
Painless upgrade of pixel series
Learning Android V from scratch - UI
【数据库】MySQL单表查询
The 8 diagrams let you see the execution sequence of async / await and promise step by step