简体   繁体   中英

How to make JAX-WS use https (http to https) for soap:address in generated wsdl

I am creating soap web service using jax-ws and spring. Here is my code

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

and in application-context.xml

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

In generated wsdl

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

but i want https because my server accepts only https requests.

Is it possible to change http to https in this case?

you may need to programmatically override the endpoint: Try to change it as

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM