Web Services 如何使JAX-WS对生成的wsdl中的soap:address使用https(http到https)

cs7cruho  于 2022-11-15  发布在  其他
关注(0)|答案(1)|浏览(219)

我正在使用jax-ws和spring创建soap web服务。

@WebService
@Service
public class SoapService {
    SoapServiceDao soapServiceDao;
    @WebMethod(exclude = true)
    public void setSoapServiceDao(SoapServiceDao soapServiceDao) {
        this.soapServiceDao = soapServiceDao;
    }

    @WebMethod
    @SOAPBinding(parameterStyle=ParameterStyle.BARE)
    public Message method1(SoapResponse soapResponse) {
        return new Message();
    }
}

以及在应用程序上下文. xml中

<wss:binding url="/soapservice">
    <wss:service>
        <ws:service bean="#soapserviceImpl" />
    </wss:service>

在生成的wsdl中

<soap:address location="http://localhost:8080/soapservice"/>

但是我想要https,因为我的服务器只接受https请求。
在这种情况下,是否可以将http更改为https?

kmynzznz

kmynzznz1#

您可能需要以编程方式覆盖端点:尝试将其更改为

MyServicePort myPort = new MyServiceInterface(new URL("https://acme.com/services/MyService.svc?wsdl")).getMyPort();
// set endpoint to use https
String endpointURL = "https://acme.com/services/MyService.svc";
BindingProvider bp = (BindingProvider) myPort;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);``
myPort.test();

相关问题