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.

  1. <dependency>
  2. <groupId>org.apache.dubbo.extensions</groupId>
  3. <artifactId>dubbo-rpc-webservice</artifactId>
  4. <version>3.3.0</version>
  5. </dependency>
  1. <dependency>
  2. <groupId>org.apache.cxf</groupId>
  3. <artifactId>cxf-rt-frontend-simple</artifactId>
  4. <version>2.6.1</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.apache.cxf</groupId>
  8. <artifactId>cxf-rt-transports-http</artifactId>
  9. <version>2.6.1</version>
  10. </dependency>

Configure Protocol

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

Configure Default Protocol

  1. <dubbo:provider protocol="webservice" />

Configure Service Protocol

  1. <dubbo:service protocol="webservice" />

Multiple Ports

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

Direct Connection

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

WSDL

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

Jetty Server (Default)

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

Configure DispatcherServlet

  1. <servlet>
  2. <servlet-name>dubbo</servlet-name>
  3. <servlet-class>org.apache.dubbo.remoting.http.servlet.DispatcherServlet</servlet-class>
  4. <load-on-startup>1</load-on-startup>
  5. </servlet>
  6. <servlet-mapping>
  7. <servlet-name>dubbo</servlet-name>
  8. <url-pattern>/*</url-pattern>
  9. </servlet-mapping>

Note

If using servlet to dispatch requests:

The protocol port <dubbo:protocol port="8080" /> must match the port of the servlet container.

The protocol context path <dubbo:protocol contextpath="foo" /> must match the context path of the servlet application.

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)