-6ren">
gpt4 book ai didi

java - 正在注册 jaxws :client as a Spring bean in Spring Boot Framework

转载 作者:行者123 更新时间:2023-11-30 03:17:58 27 4
gpt4 key购买 nike

我看到一个 java 项目,其中使用 WSDL2Java 命令生成 Web 服务客户端。该项目还包含一个带有以下配置的 spring.xml :

<jaxws:client
id = "com.xyz.connector"
serviceClass = "com.xyz.XYZServicePort"
address = "<endpoint url from config>"
bus="XYZServiceBus">
</jaxws:client>
<bean id = "XYZPasswordCallback" class = "com.xyz.ClientPasswordCallback">
<property name = "password" value = "<password from config>"/>
</bean>
<bean id = "logInbound" class = "org.apache.cxf.interceptor.LoggingInInterceptor"/>
<bean id = "logOutbound" class = "org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<cxf:bus bus="XYZServiceBus">
<cxf:inInterceptors>
<ref bean = "logInbound"/>
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean = "logOutbound"/>
<bean class = "org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<constructor-arg>
<map>
<entry key = "action" value = "UsernameToken"/>
<entry key = "addUTElements" value = "Unique ID Created"/>
<entry key = "user" value = "<user id from config>"/>
<entry key = "passwordType" value = "PasswordText"/>
<entry key = "passwordCallbackRef" value-ref = "XYZServiceBus"/>
</map>
</constructor-arg>
</bean>
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<ref bean = "logOutbound"/>
</cxf:outFaultInterceptors>
<cxf:inFaultInterceptors>
<ref bean = "logInbound"/>
</cxf:inFaultInterceptors>
</cxf:bus>

有一个 Java 类文件,上面列出的 spring.xml 已使用下面的注释加载。

@ImportResource({ /*"classpath:config.xml",*/ "classpath*:META-INF/application-context.xml", "classpath*:META-INF/spring.xml" })

XYZServicePort 使用类中的注释 Autowiring 。然后,XYZServicePort 用于调用服务公开的操作。

与 spring.xml 相关的 xml 片段是添加到使用 wsdl2java 命令生成的 Web 服务客户端项目的唯一配置文件。我在 spring.xml 中没有看到任何配置,也没有在将 XYZServicePort 定义为 bean 的代码中看到任何注释。 spring.xml 中的 xml 片段是否以某种方式将 XYZServicePort 转换为 spring bean?

最佳答案

<强> <jaxws:client>可以在客户端使用。您将为它提供一个 bean 名称、服务接口(interface)和服务 URL,CXF 将创建一个具有指定名称的 bean,实现服务接口(interface),并调用远程 SOAP 服务,该服务需要在 Spring 中注入(inject)到该客户端需要调用的位置。

有关更多详细信息,请参阅以下 URL:

http://cxf.apache.org/docs/writing-a-service-with-spring.html

http://cxf.apache.org/docs/jax-ws-configuration.html

希望这会有所帮助!

关于java - 正在注册 jaxws :client as a Spring bean in Spring Boot Framework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32085875/

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