如何通过SSL身份验证发送SOAP请求?

时间:2018-09-07 13:09:20

标签: java ssl soap certificate ssl-certificate

我想通过*ngIf="isLoading"发送soap请求

我可以使用当前代码正常使用服务

ssl authentication

但是除了我需要添加URL url = TransactionImports.class.getResource("agentWsdl.wsdl"); AgentServices agentServices = new AgentServices_Service(url, new QName("agentTargetNameSpace", "AgentServices")).getAgentServicesPort(); BindingProvider bindingProvider = (BindingProvider) agentServices; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, applicationProperties.getProperty("service.url")); bindingProvider.getRequestContext().put(BindingProviderProperties.REQUEST_TIMEOUT, applicationProperties.getProperty("service.timeout")); return agentService; 之外,我的证书是ssl authentication文件

我修改了代码以添加此证书

my-certificate.pfx

,但是它不起作用。尝试发送请求时出现错误

错误看起来像String keyPassphrase = "myPassword"; AgentServices agentServices = new AgentServices_Service(url, new QName("agentTargetNamespace", "AgentServices")).getAgentServicesPort(); SSLContextBuilder sslBuilder = SSLContexts.custom(); SSLContext sslContext = sslBuilder.loadTrustMaterial(ClientUtil.class.getResource("/my-certificate.pfx"), "myPassword".toCharArray()) .build(); BindingProvider bindingProvider = (BindingProvider) agentServices; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, applicationProperties.getProperty("service.url")); bindingProvider.getRequestContext().put(BindingProviderProperties.REQUEST_TIMEOUT, applicationProperties.getProperty("service.timeout")); bindingProvider.getRequestContext().put(BindingProviderProperties.SSL_SOCKET_FACTORY, sslContext.getSocketFactory());

这是我第一次尝试使用java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer发送请求,我做错了什么?您能为我提供任何好的解决方案的建议,如何设置证书以致电服务机构?

0 个答案:

没有答案