Dubbo's WebService protocol use

Source: Internet
Author: User

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

    1. You need to specify <dubbo:protocol server= "servlet";.

    2. 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.

    3. When a consumer refers, the URL needs to be in the application context or it cannot be accessed.

    4. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.