【问题标题】:CXF Code First SOAP Web Service Endpoint ProtocolCXF 代码优先 SOAP Web 服务端点协议
【发布时间】:2020-07-16 05:10:53
【问题描述】:

我正在实现 Code first cxf Web 服务。 cxf 如何决定生成的 wsdl 的 soap:address 部分?是否使用已部署机器的主机名?

另外,我可以通过编程方式或在部署的应用程序上通过配置将端点协议从 http 更改为 https 吗?

【问题讨论】:

    标签: web-services soap cxf code-first


    【解决方案1】:

    您可以为此使用 Spring。

    您必须为接口服务创建一个 impl。

    @WebService(endpointInterface = "com.services.MyAwesomeService")
    public class MyAwesomeServiceImpl implements MyAwesomeService {
    
        @Override
        public String sayHi(String text) {
            return "Hello " + text;
        }    
    
    }
    

    并通过 Spring 进行配置。

    
    @Configuration
    public class ServiceConfig {
    
        @Bean(name = Bus.DEFAULT_BUS_ID)
        public SpringBus springBus() {
            return new SpringBus();
        }   
    
        @Bean(name = "myAwesomeService")
        public MyAwesomeServiceImpl myAwesomeService() {
            return new MyAwesomeServiceImpl();
        }
        
        @Bean
        public Endpoint endpoint() {
            EndpointImpl endpoint = new EndpointImpl(springBus(), myAwesomeService());
            endpoint.publish("/MyAwesomeService");
            
            return endpoint;
        }
    }
    

    这样做之后。您将在路径/MyAwesomeService 中发布您的服务。

    配置HTTPS协议,建议你在应用容器(Tomcat)或专用前端(Apache、F5等)配置

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多