In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, Xiaobian will bring you about webservice based on servlet container implementation demo, the article is rich in content and professional analysis and description for everyone, after reading this article, I hope you can gain something.
The previous introduction of dubboframework based on dubbo protocol demo, this is more than to introduce another protocol-webservice, in fact, it is based on http protocol implementation, exposure wenservice standardized interface, using apache-cxf implementation. There are many other implementations of dubbo, such as rmi,hessian,redis, plain http, etc.
Here are the demo steps:
1. Create a new dynamic web project, named dubbo-webservice, as shown in the figure below:
2. Create a new interface DubboService
package com.enson.webservice.service;public interface DubboService { public String printWord(String word);}
3. New interface implementation class DubboServiceImpl
package com.enson.webservice.service.impl;import java.text.SimpleDateFormat;import java.util.Date;import com.enson.webservice.service.DubboService;public class DubboServiceImpl implements DubboService { @Override public String printWord(String word) { String outWord = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS") .format(new Date()) + word; System.out.println(outWord); return outWord; }}
4. Create a new configuration file spring\dubbo.xml
4. Configure web.xml
dubbo-webservice index.jsp contextConfigLocation classpath:spring/*.xml org.springframework.web.context.ContextLoaderListener dubbo com.alibaba.dubbo.remoting.http.servlet.DispatcherServlet 1 dubbo /services/*
Deploy the project to tomcat
Note: The servlet-api that dubbo must use is version 2.5. Tomcat loads version 2.3 first by default. Find the lib folder in the tomcat installation path and replace servlet-api with servlet-api-2.5.jar.
Start Zookeeper first, then Tomcat.
Visit http://localhost:8080/dubbo-webservice/services/com.enson.webservice.service.DubboService? wsdl
Note: The address is missing. wsdl"will report cxf error.
The above is how the demo of webservice based on servlet container is shared by Xiaobian. If you happen to have similar doubts, you may wish to refer to the above analysis for understanding. If you want to know more about it, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.