All Products
Search
Document Center

Using XML

Last Updated: Aug 21, 2020

This topic describes how to publish and reference services in the XML mode. The following are the tabs in the XML configuration and their meanings.

  • sofa:service indicates publishing a service.
  • sofa:reference indicates referencing a service.
  • sofa:binding indicates the protocol for service publication or reference.

Code example of publishing a service:

  1. <bean id="personServiceImpl" class="com.alipay.sofa.boot.examples.demo.rpc.bean.PersonServiceImpl"/>
  2. <sofa:service ref="personServiceImpl" interface="com.alipay.sofa.boot.examples.demo.rpc.bean.PersonService">
  3. <sofa:binding.bolt/>
  4. </sofa:service>

You can publish a service by using multiple protocols.

  1. <sofa:service ref="personServiceImpl" interface="com.alipay.sofa.boot.examples.demo.rpc.bean.PersonService">
  2. <sofa:binding.bolt/>
  3. <sofa:binding.rest/>
  4. <sofa:binding.dubbo/>
  5. </sofa:service>

Code example of referencing a service:

  1. <sofa:reference id="personReferenceBolt" interface="com.alipay.sofa.boot.examples.demo.rpc.bean.PersonService">
  2. <sofa:binding.bolt/>
  3. </sofa:reference>

You can also reference a service by using other protocols.

  1. <sofa:reference id="personReferenceRest" interface="com.alipay.sofa.boot.examples.demo.rpc.bean.PersonService">
  2. <sofa:binding.rest/>
  3. </sofa:reference>