如何更改 Spring JaxWs 代理的端口?
我有一个基于 Spring 的工作 Web 服务客户端,定义为:
<bean id="myService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
<property name="wsdlDocumentUrl" value="classpath:/ex/MyService.wsdl" />
<property name="namespaceUri" value="http://ex.tld/namespace" />
<property name="serviceName" value="MyService" />
<property name="portName" value="MyServicePort01" />
<property name="serviceInterface" value="ex.MyService" />
</bean>
我需要在不同端点的列表上访问相同的服务。由于列表是动态的,我不能简单地为此配置几个 Spring JaxWsPortProxy bean。
我可以动态更改绑定吗?我怎样才能解决这个问题,同时仍然为 WS 客户端利用 Spring 设施?
I have a working web service client based on Spring, defined as:
<bean id="myService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
<property name="wsdlDocumentUrl" value="classpath:/ex/MyService.wsdl" />
<property name="namespaceUri" value="http://ex.tld/namespace" />
<property name="serviceName" value="MyService" />
<property name="portName" value="MyServicePort01" />
<property name="serviceInterface" value="ex.MyService" />
</bean>
I need to access the same service on a list of different endpoints. Since the list is dynamic I cannot simply configure several Spring JaxWsPortProxy beans for this.
Can I change the binding dynamically? How can I solve this while still leveraging Spring facilities for WS clients?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只是更改了代理的端点地址:
((BindingProvider)myService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://new/endpoint/address");
如上所示,Spring 返回的代理可以转换为 BindingProvider (就像普通的 JaxWs 代理一样)。
如果有人采用此方法,请注意同步问题。
I simply changed the endpoint address of the proxy:
((BindingProvider)myService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://new/endpoint/address");
As seen above, the proxy that Spring returns can be casted to a BindingProvider (like a normal JaxWs proxy).
If someone adopts this, beware of synchronization issues.
我是在xml中配置的,和你一样。
之后,在 postConsruct 设置端点,并调用 afterPropertiesSet:
I configured in xml, as you.
After, in postConsruct set endpoint, and call afterPropertiesSet: