【问题标题】:Grails injected services exposed as web methods in cxfGrails 注入的服务在 cxf 中暴露为 Web 方法
【发布时间】:2013-05-16 06:02:08
【问题描述】:

我有一个使用 Grails Cxf 插件公开为 jaxws 的服务类。在我的服务中,我必须注入另一个在我的 Web 服务中使用的服务类。如果我公开服务字段,我会生成如下不必要的服务方法:

retrieveLastRecordUpdateDate
setPricingContractService
retrieveRecordsUpdatedFromDate
retrieveAllRecordsByInsurance
getPricingContractService

如果我将字段设为私有,我将无法注入服务类。如何既注入服务又不将其公开为 Web 服务?简化代码如下:

class PricingContractWebService {

static expose = EndpointType.JAX_WS

def pricingContractService // private?

@WebMethod( operationName="retrieveAllRecordsByInsurance" )
@WebResult( name="pricingContractList" )
@XmlElement(name="healthCareCompany", required=true)
List<PricingContractDTO> retrieveAllRecordsByInsurance(@WebParam(partName = "HealthCareCompany", name = "healthCareCompany", ) final HealthCareCompany healthCareCompany) {

    def pricingContractDTOList = []

    pricingContractDTOList
}

@WebMethod( operationName="retrieveLastRecordUpdateDate" )
@WebResult( name="lastUpdateDate" )
Date retrieveLastRecordUpdateDate() {

}

@WebMethod( operationName="retrieveRecordsUpdatedFromDate" )
@WebResult( name="pricingContractList" )
@XmlElement(name="updateDate", required=true)
List<PricingContractDTO> retrieveRecordsUpdatedFromDate(@WebParam(name = "updateDate") final Date date) {

    def pricingContractDTOList = []

    pricingContractDTOList
}

}

【问题讨论】:

    标签: grails dependency-injection jax-ws cxf


    【解决方案1】:

    您应该将服务端点设为私有并在端点声明之前添加@Autowired:

    @Autowired
    private PricingContractService pricingContractService
    

    【讨论】:

      猜你喜欢
      • 2016-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-20
      • 1970-01-01
      • 2019-07-22
      相关资源
      最近更新 更多