如何更改Spring JaxWs代理的端口?
我有一个基于Spring的工作web服务客户端,定义如下:如何更改Spring JaxWs代理的端口?,spring,jax-ws,Spring,Jax Ws,我有一个基于Spring的工作web服务客户端,定义如下: <bean id="myService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean"> <property name="wsdlDocumentUrl" value="classpath:/ex/MyService.wsdl" /> <property name="namespaceUri"
<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>
我需要访问不同端点列表上的相同服务。由于列表是动态的,我不能简单地为此配置几个SpringJAXWSPortProxy bean
我可以动态更改绑定吗?如何在仍然利用Spring工具支持WS-Client的情况下解决此问题?我只是更改了代理的端点地址:
((BindingProvider)myService.getRequestContext().put(BindingProvider.ENDPOINT\u ADDRESS\u属性)http://new/endpoint/address");代码>
如上所述,Spring返回的代理可以强制转换为BindingProvider(类似于普通的JaxWs代理)
如果有人采用这种方法,请注意同步问题。我用xml进行了配置,与您一样。
之后,在后构造中设置端点,并调用AfterPropertieSet:
@Autowired
private JaxWsPortProxyFactoryBean myService;
@PostConstruct
public void init() {
myService.setEndpointAddress("http://new/endpoint/address");
myService.afterPropertiesSet();
}