Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jax-ws client spring xml bean configuration to java based configuration?

Tags:

Can you help me convert following spring xml based configuration to java based configuration of beans?

<jaxws:client id="helloClient"
                  serviceClass="demo.spring.HelloWorld"
                  address="http://localhost:9002/HelloWorld" />
like image 214
John Penn Avatar asked Apr 24 '16 17:04

John Penn


1 Answers

You just need to declare a bean in any of your configuration classes with the properties you have in your question. It should look something like this:

@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();
}

Your method will return an object of the Service class. You need a Jax proxy factory bean to set the properties and then create the client (cast it to your service class) and return it.

like image 131
cvetanov Avatar answered Oct 07 '22 02:10

cvetanov