gpt4 book ai didi

grails - 使用 DSL 而不是 resource.xml 在 resources.groovy 中配置 CXF 服务

转载 作者:行者123 更新时间:2023-12-02 14:45:11 26 4
gpt4 key购买 nike

我在 grails 中成功创建了 cxf wsdl web-services。现在我想配置 cxf 简单的前端端点。

我在 grails 项目的 resource.xml 文件中成功配置了 cxf 端点。

像..

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:simple="http://cxf.apache.org/simple"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd
http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<!--create CXF service-->
<simple:server serviceClass="com.j2.signup.FaxSignupService" address="/FaxSignupService">

</simple:server>
</beans>

但我希望在 resource.groovy DSL 文件中使用相同的 cxf 端点配置,而不是创建新的 resource.xml。

有人对此有想法吗?

最佳答案

您可以使用 importBeans代替<import>元素

importBeans('classpath:META-INF/cxf/cxf.xml')

对于 <simple:server>您可以直接在 DSL 中复制它(参见 this section of the user guide 末尾的“使用 Spring 命名空间”)
xmlns simple:'http://cxf.apache.org/simple'
simple.server(serviceClass:"com.j2.signup.FaxSignupService",
address:"/FaxSignupService")

如果您的 FaxSignupService类本身需要由 Spring 注入(inject)依赖项,那么您也需要将其声明为顶级 bean
faxSignupService(com.j2.signup.FaxSignupService) { bean ->
bean.autowire = "byName"
}
xmlns simple:'http://cxf.apache.org/simple'
simple.server(serviceClass:"com.j2.signup.FaxSignupService",
serviceBean:"#faxSignupService",
address:"/FaxSignupService")

(注意,如果 FaxSignupServicegrails-app/services 下的真正 Grails 服务,则默认情况下它已经注册为 bean,不需要额外的 bean 定义,只需将 serviceBean:'#faxSignupService' 添加到 simple.server 就足够了。)

关于grails - 使用 DSL 而不是 resource.xml 在 resources.groovy 中配置 CXF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13469678/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com