Common interfaces and implementation classes
public interface Wsservice
{
String SayHello (string msg);
}
public class Wsserviceimpl implements Wsservice
{
@Override
public string SayHello (String msg)
{
Return "Hello" + msg;
}
}
Dubbo Service Provider Configuration
<?xml version= "1.0" encoding= "UTF-8"?>
<beans xmlns= "Http://www.springframework.org/schema/beans"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo= "Http://code.alibabatech.com/schema/dubbo"
Xsi:schemalocation= "Http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans.xsd
Http://code.alibabatech.com/schema/dubbo
Http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
<!--provider application information for computing dependencies--
<dubbo:application name= "Dubbo-webservice-app-provider"/>
<!--<dubbo:registry protocol= "multicast" address= "224.5.6.7:1234"/>--
<!--if server:servlet, the port must be consistent with the servlet container port while the ContextPath is the same context as the Servlet app-
<dubbo:protocol name= "WebService" port= "8080" server= "servlet"/>
<dubbo:service interface= "Com.dubbo.webservice.WsService" ref= "Wsservice" registry= "N/a" path= "service"/>
<bean id= "Wsservice" class= "Com.dubbo.webservice.WsServiceImpl"/>
</beans>
Dubbo Service Consumer Configuration
<?xml version= "1.0" encoding= "UTF-8"?>
<beans xmlns= "Http://www.springframework.org/schema/beans"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo= "Http://code.alibabatech.com/schema/dubbo"
Xsi:schemalocation= "Http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans.xsd
Http://code.alibabatech.com/schema/dubbo
Http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
<!--provider application information for computing dependencies--
<dubbo:application name= "Dubbo-webservice-app-consumer"/>
<!--use the multicast broadcast registry to expose the service address--
<!--<dubbo:registry address= "multicast://224.5.6.7:1234"/>--
<!--declaring a service interface that needs to be exposed--
<dubbo:reference interface= "Com.dubbo.webservice.WsService" id= "Wsservice" url= "webservice://localhost:8080/ Projectbuild/service "registry=" N/a "/>
</beans>
Web. XML configuration
<servlet>
<servlet-name>dubbo</servlet-name>
<servlet-class>com.alibaba.dubbo.remoting.http.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dubbo</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Dependent configuration Files
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-simple</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.6.1</version>
</dependency>
Precautions
You need to specify <dubbo:protocol server= "servlet";.
The jar needs to use the 2.6.1 version, and the high version seems to have a problem and the consumer cannot access it.
When a consumer refers, the URL needs to be in the application context or it cannot be accessed.
For servlet services, the port and context must be consistent with the port and context of the application server.
Legacy issues
Mutual use of 1.dubbo-webservice and standard WebService
This article is from the "Traveler" blog, so be sure to keep this source http://881206524.blog.51cto.com/10315134/1924889
Dubbo's WebService protocol use