springboot整合webservice修改cxf自动生成wsdl的soap:address location

文章讲述了如何在webservice接口上线过程中,通过设置`publishedEndpointUrl`来替换真实业务服务的IP和端口,以保护其安全性。作者提供了使用SpringBus和Endpoint的配置示例,展示了如何在WSDL文件中替换`<soap:addresslocation>`地址。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

近期系统中的webservice接口要上线

通过http://localhost:8080/webServices/testService?wsdl走网关访问时,返回的<soap:address location>是真实业务服务的ip:port。因为我们只能暴露网关的ip和端口,需要将真实服务的ip和端口隐藏起来。

    @Bean
    public Endpoint messagePoint() throws IOException {
        EndpointImpl endpoint = new EndpointImpl(this.springBus(), this.testService);
        endpoint.setPublishedEndpointUrl("http://yourdomain.com/yourServicePath");
        endpoint.publish("/testService");
        return endpoint;
    }

这时候我们在创建Endpoint的时候,可以通过配置setPublishedEndpointUrl()展示wsdl文件中<soap:address location>发布地址。

效果如下:

<wsdl:service name="testService">
<wsdl:port binding="tns:testServiceSoapBinding" name="TestServiceImplPort">
<soap:address location="http://yourdomain.com/yourServicePath"/>
</wsdl:port>
</wsdl:service>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值