311.6.2. Webservice Server

使用以下路由设置 Web 服务服务器,该服务器使用类 customerServiceImpl 侦听 jms 队列 customerServiceQueue 并处理请求。本课程的 customerServiceImpl 应实施接口 CustomerService。不是直接实例化服务器类,而是可以作为常规 bean 在 spring 上下文中定义。

SoapJaxbDataFormat soapDF = new SoapJaxbDataFormat("com.example.customerservice", new ServiceInterfaceStrategy(CustomerService.class));
CustomerService serverBean = new CustomerServiceImpl();
from("jms://queue:customerServiceQueue")
  .onException(Exception.class)
    .handled(true)
    .marshal(soapDF)
  .end()
  .unmarshal(soapDF)
  .bean(serverBean)
  .marshal(soapDF);