2013-07-04 70 views
0

我有如下簡化一個CXF Web服務。我的問題是,如果我注入像下面這樣的服務,生成的wsdl也會有setParameterService/getParameterService和getMessageSource/setMessageSource方法。如果我不想將它們暴露爲Web服務,我應該怎麼做?Grails中CXF Web服務注入服務引起的getter/setter產生

@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 
} 

}

回答

1

我簡化了代碼一點,但是這應該讓你跑。使服務端點私人,然後加以註釋與@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() 
    } 
} 
+0

您也可以刪除靜態暴露= EndpointType.JAX_WS因爲你對@WebService標註有該做同樣的事情。 – Christian

+0

我說這個例子GitHub的項目在https://github.com/Grails-Plugin-Consortium/grails-cxf/blob/master/grails-app/services/org/grails/cxf/test/OrganizationService.groovy和你可以使用SOAP UI調用它,如果你得到了項目源代碼並對它執行一個運行應用程序並使用localhost:8080/grails-cxf/services/organization?wsdl – Christian

0

我從來沒有做過它一個Grails應用程序,但通常你可以使用@XmlTransient。您也可能需要在課堂上使用@XmlAccessorType(XmlAccessType.FIELD)

0

您可以取代:

@WebService(portName = "OrganizationPort", serviceName = "OrganizationService", name = "OrganizationService", targetNamespace = "http://akum.compugroup.com") 

有:

@GrailsCxfEndpoint 

@GrailsCxfEndpoint自動排除所有的getter和setter。

但隨後你將失去設置PORTNAME服務名目標名稱的能力。這正是我目前遇到的問題。

混合@GrailsCxfEndpoint@WebService也沒有解決,因爲它再次暴露了getter和setter方法。