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 PasswordAuthentication 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;
}