gpt4 book ai didi

java - 如何在不使用默认身份 validator 的情况下使用 JAXWS 访问受密码保护的 WSDL?

转载 作者:搜寻专家 更新时间:2023-11-01 00:53:20 24 4
gpt4 key购买 nike

下面的 wsdlLocation 受密码保护,但偏执狂让我对为应用程序设置默认 Authenticator 感到不舒服。如何在不使用默认身份 validator 的情况下设置身份验证?

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

最佳答案

当然,一种解决方法是将 wsdl 下载到本地文件并改用该文件。不过,如果不必这样做就好了。

关于java - 如何在不使用默认身份 validator 的情况下使用 JAXWS 访问受密码保护的 WSDL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3520525/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com