2016-04-24 80 views

回答

2

你只需要在你的任何配置類中用你在問題中的屬性聲明一個bean。 它應該是這個樣子:

@Bean(name = "helloClient") // this is the id 
public HelloWorld helloWorld() { 
    String address = "http://localhost:9002/HelloWorld"; 
    JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean(); 
    factoryBean.setServiceClass(HelloWorld.class); 
    factoryBean.setAddress(address); 

    return (HelloWorld) factoryBean.create(); 
} 

你的方法將返回服務類的對象。 您需要Jax代理工廠bean來設置屬性,然後創建客戶端(將其轉換爲您的服務類)並將其返回。