Get the App
SLTechnology News&Howtos  ›  Servers  › 

What is the implementation of webservice based on servlet container demo

Shulou Source: shulou.com Published: 2022-06-01 01:46:52 09月15日 Update

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.

Tags: Interface container content file version analysis configuration ordinary professional small and medium rich in content name address that is folder article way more standard step Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Docker MySQL macOS Xiaomi