Webservice Protocol

Webservice Protocol

Feature Description

WebService-based remote call protocol, implemented based on Apache CXF frontend-simple and transports-http. Supported in versions 2.3.0 and above.

CXF is an Apache open-source RPC framework formed by the merger of Xfire and Celtix.

  • Number of connections: Multiple connections
  • Connection method: Short connections
  • Transport protocol: HTTP
  • Transport method: Synchronous transmission
  • Serialization: SOAP text serialization
  • Applicable scenarios: System integration, cross-language calls

It can interoperate with native WebService services, meaning:

  • The provider exposes the service via Dubbo’s WebService protocol, and the consumer directly calls using the standard WebService interface,
  • Or the provider uses standard WebService to expose services, and the consumer calls using Dubbo’s WebService protocol.

Constraints

  • Parameters and return values must implement the Serializable interface
  • Parameters should preferably use basic types and POJOs

Usage Scenarios

Publishing a service (internally/externally), regardless of client type or performance, it is recommended to use webservice. If the server has determined to use webservice, the client has no choice and must use webservice.

Usage Method

Dependencies

Starting from Dubbo 3, the Webservice protocol is no longer embedded in Dubbo and needs to be imported as a separate module.

<dependency>
    <groupId>org.apache.dubbo.extensions</groupId>
    <artifactId>dubbo-rpc-webservice</artifactId>
    <version>3.3.0</version>
</dependency>
<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>

Configure Protocol

<dubbo:protocol name="webservice" port="8080" server="jetty" />

Configure Default Protocol

<dubbo:provider protocol="webservice" />

Configure Service Protocol

<dubbo:service protocol="webservice" />

Multiple Ports

<dubbo:protocol id="webservice1" name="webservice" port="8080" />
<dubbo:protocol id="webservice2" name="webservice" port="8081" />

Direct Connection

<dubbo:reference id="helloService" interface="HelloWorld" url="webservice://10.20.153.10:8080/com.foo.HelloWorld" />

WSDL

http://10.20.153.10:8080/com.foo.HelloWorld?wsdl

Jetty Server (Default)

<dubbo:protocol ... server="jetty" />
<dubbo:protocol ... server="servlet" />

Configure DispatcherServlet

<servlet>
         <servlet-name>dubbo</servlet-name>
         <servlet-class>org.apache.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>
Last modified September 30, 2024: Translate (22d3d83a3b)