在Grails Cxf web服务中注入服务会导致生成getter/setter
我有一个cxf web服务,简化如下。我的问题是,如果我像下面这样注入服务,生成的wsdl也将具有setParameterService/getParameterService和getMessageSource/setMessageSource方法。如果我不想将它们公开为Web服务,该怎么办在Grails Cxf web服务中注入服务会导致生成getter/setter,grails,dependency-injection,cxf,Grails,Dependency Injection,Cxf,我有一个cxf web服务,简化如下。我的问题是,如果我像下面这样注入服务,生成的wsdl也将具有setParameterService/getParameterService和getMessageSource/setMessageSource方法。如果我不想将它们公开为Web服务,该怎么办 @WebService(portName = "OrganizationPort", serviceName = "OrganizationService", name = "OrganizationSer
@WebService(portName = "OrganizationPort", serviceName = "OrganizationService", name = "OrganizationService", targetNamespace = "http://akum.compugroup.com")
@SOAPBinding(parameterStyle = ParameterStyle.WRAPPED, use = Use.LITERAL, style = Style.DOCUMENT)
class OrganizationWebService {
def parameterService
def messageSource
static expose = EndpointType.JAX_WS
@WebMethod
@WebResult
Organization kurumSorgulama(@WebParam(partName = "KurumSorgulamaTalep", name = "KurumSorgulamaTalep", targetNamespace = "http://akum.compugroup.com") String kurumKodu) {
return organization
}
@WebMethod
@WebResult
Organization authorize(@WebParam(partName = "KurumSorgulamaTalep", name = "KurumSorgulamaTalep", targetNamespace = "http://akum.compugroup.com") String kurumKodu) {
return organization
}
}我从未为Grails应用程序做过,但通常您可以使用
@xmltransive
。此外,您可能需要在类级别使用@xmlacessortype(xmlacesstype.FIELD)
。您可以替换:
@WebService(portName = "OrganizationPort", serviceName = "OrganizationService", name = "OrganizationService", targetNamespace = "http://akum.compugroup.com")
与:
@GrailsCxfEndpoint自动排除所有getter和setter
但是,您将失去设置portName、serviceName、name和targetNamespace的能力。这正是我目前面临的问题
将@GrailsCxfEndpoint与@WebService混合使用也不是解决方案,因为它会再次公开getter和setter。我将代码简化了一点,但这应该可以让您运行起来。将服务端点设置为私有,然后使用@AutoWired对其进行注释
@WebService(portName = "OrganizationPort", serviceName = "OrganizationService", name = "OrganizationService", targetNamespace = "http://akum.compugroup.com")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED, use = SOAPBinding.Use.LITERAL, style = SOAPBinding.Style.DOCUMENT)
class OrganizationService {
@Autowired
private BoatService boatService
@Autowired
private CarService carService
static expose = EndpointType.JAX_WS
@WebMethod
@WebResult
String goFish(@WebParam(partName = "KurumSorgulamaTalep", name = "KurumSorgulamaTalep", targetNamespace = "http://akum.compugroup.com") String kurumKodu) {
boatService.fish()
}
@WebMethod
@WebResult
String goHonk(@WebParam(partName = "KurumSorgulamaTalep", name = "KurumSorgulamaTalep", targetNamespace = "http://akum.compugroup.com") String kurumKodu) {
carService.honkHorn()
}
}
您还可以删除static expose=EndpointType.JAX_WS,因为您在那里有@WebService注释,它也可以做同样的事情。我在的github项目中添加了这个示例,如果您获得项目源并在其上运行应用程序并使用localhost:8080/grails cxf/services/organization?wsdl,您可以使用SOAP UI调用它
@WebService(portName = "OrganizationPort", serviceName = "OrganizationService", name = "OrganizationService", targetNamespace = "http://akum.compugroup.com")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED, use = SOAPBinding.Use.LITERAL, style = SOAPBinding.Style.DOCUMENT)
class OrganizationService {
@Autowired
private BoatService boatService
@Autowired
private CarService carService
static expose = EndpointType.JAX_WS
@WebMethod
@WebResult
String goFish(@WebParam(partName = "KurumSorgulamaTalep", name = "KurumSorgulamaTalep", targetNamespace = "http://akum.compugroup.com") String kurumKodu) {
boatService.fish()
}
@WebMethod
@WebResult
String goHonk(@WebParam(partName = "KurumSorgulamaTalep", name = "KurumSorgulamaTalep", targetNamespace = "http://akum.compugroup.com") String kurumKodu) {
carService.honkHorn()
}
}