【问题标题】:Jax-ws client spring xml bean configuration to java based configuration?Jax-ws 客户端 spring xml bean 配置到基于 java 的配置?
【发布时间】:2016-08-18 00:15:03
【问题描述】:

您能帮我将以下基于 Spring xml 的配置转换为基于 java 的 bean 配置吗?

<jaxws:client id="helloClient"
                  serviceClass="demo.spring.HelloWorld"
                  address="http://localhost:9002/HelloWorld" />

【问题讨论】:

    标签: java spring jax-ws spring-java-config


    【解决方案1】:

    您只需要在任何配置类中声明一个具有您问题中的属性的 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();
    }
    

    您的方法将返回 Service 类的对象。 您需要一个 Jax 代理工厂 bean 来设置属性,然后创建客户端(将其转换为您的服务类)并返回它。

    【讨论】:

      猜你喜欢
      • 2013-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-25
      • 2012-02-01
      • 1970-01-01
      • 2017-06-23
      相关资源
      最近更新 更多