开发者

How do I access a password-protected WSDL using JAXWS without using default Authenticator?

开发者 https://www.devze.com 2023-01-12 10:11 出处:网络
wsdlLocation below is password protected, but paranoia makes me uncomfortable with having set a default Authenticator for the application. How can I set authentication without using a default Authenti

wsdlLocation below is password protected, but paranoia makes me uncomfortable with having set a default Authenticator for the application. How can I set authentication without using a default Authenticator?

protected Orders getOrdersPort(String wsdlLocation, String namespaceURI) {
    Authenticator.setDefault(new Authenticator() {
        @Override
        protected P开发者_Python百科asswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication("username", "password".toCharArray());
        }
    });
    OrdersService service = new OrdersService(createUrlThrowRuntimeException(wsdlLocation), new QName(namespaceURI,
            "OrdersService"));
    Orders ordersPort = service.getOrdersSoap12();
    setConnectionTimeout(ordersPort);
    return ordersPort;
}


One workaround is of course to download the wsdl to a local file and use that file instead. Would be nice to not have to do that though.

0

精彩评论

暂无评论...
验证码 换一张
取 消