gpt4 book ai didi

java - 将摘要身份验证添加到 SOAP 请求

转载 作者:行者123 更新时间:2023-12-01 23:35:48 25 4
gpt4 key购买 nike

我正在尝试将摘要身份验证(用户名和密码)添加到我的 SOAP 请求中,该请求使用 org.apache.cxf (3.3.2) 进行类生成。我尝试使用 BindingProvider 附加用户名和密码没有成功:

MyServiceGeneratedClass soapClient = new MyServiceGeneratedClass();
MyServicePort port = soapClient.getMyServicePort();
BindingProvider bindingProvider = (BindingProvider)port;
bindingProvider.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "mySecretUsername");
bindingProvider.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "mySecretPassword");

生成的 SOAP 请求不包含用户和密码。

有什么想法吗?

最佳答案

类似的帖子是关于Digest Authentication With Apache CXF

也许该解决方案也适合您:

MyService myService = new MyService("wsdl-url");
MyServicePort myServicePort = myService.getMyServicePort();

Client client = ClientProxy.getClient(myServicePort);
HTTPConduit http = (HTTPConduit) client.getConduit();

AuthorizationPolicy authPolicy = new AuthorizationPolicy();
authPolicy.setAuthorizationType("Digest");
authPolicy.setUserName("user");
authPolicy.setPassword("myPassword");
http.setAuthorization(authPolicy);

myServicePort.doSomething();

关于java - 将摘要身份验证添加到 SOAP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58277717/

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