我们正在Java开发一个应用程序,因为几周前我们有一个无法解决的问题。这是对Web服务的呼吁,以获取带有证书的一系列数据。我们遵循以下步骤来创建工件和随后的呼叫
1.我们在Windows CMD WSIMPORT -保存https://xxx/xxx/xxx.svc中启动WSIMPORT命令?singlewsdl -s c: users user mvelasco documents xx xxxx src src main java -xauthfile c: users users mvelasco mvelasco authwsdl.txt它会生成一系列具有WS和DATACONCONTARCTLACT的类别的类。在此处输入图像描述
- 我们已经导入证书
KEYTOOL -IMPORTCERT -KEYSTORE" C: PROGRAM FILES JAVA JDK1.7.0_60 JRE JRE lib lib lib security cacerts" -file -File -Alias x
-
我们创建了一个具有以下WS调用方法
的类私人静态void llamadaalservicio(({ idocumentosservice port =(new documenservice((( 。 bindingProvider prov =(bindingProvider(端口; log.error("用户名:" ContextProperties.getAsiturwsusuario(((; log.error("密码:" ContextProperties.getAsiturwspassword(((;
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, ContextProperties.getAsiturWsUsuario()); prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, ContextProperties.getAsiturWsPassword()); ArrayOfAttachmentDTO arrAttachmentDTO = port .getAllAttachments("1234567");
}
DocormenoService类由JAX-WS生成
@WebServiceClient(name = "DocumentosService", targetNamespace = "http://tempuri.org/", wsdlLocation = "https://xxx/xxx/xxx.svc?singleWsdl") public class DocumentosService extends Service {
private final static URL DOCUMENTOSSERVICE_WSDL_LOCATION;
private final static WebServiceException DOCUMENTOSSERVICE_EXCEPTION;
private final static QName DOCUMENTOSSERVICE_QNAME = new QName("http://tempuri.org/", "DocumentosService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("https://xxx/xxx/xxx.svc?singleWsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
DOCUMENTOSSERVICE_WSDL_LOCATION = url;
DOCUMENTOSSERVICE_EXCEPTION = e;
}
public DocumentosService() {
super(__getWsdlLocation(), DOCUMENTOSSERVICE_QNAME);
}
public DocumentosService(WebServiceFeature... features) {
super(__getWsdlLocation(), DOCUMENTOSSERVICE_QNAME, features);
}
public DocumentosService(URL wsdlLocation) {
super(wsdlLocation, DOCUMENTOSSERVICE_QNAME);
}
public DocumentosService(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, DOCUMENTOSSERVICE_QNAME, features);
}
public DocumentosService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public DocumentosService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns IDocumentosService
*/
@WebEndpoint(name = "BasicHttpBinding_IDocumentosService")
public IDocumentosService getBasicHttpBindingIDocumentosService() {
return super.getPort(new QName("http://tempuri.org/", "BasicHttpBinding_IDocumentosService"), IDocumentosService.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns IDocumentosService
*/
@WebEndpoint(name = "BasicHttpBinding_IDocumentosService")
public IDocumentosService getBasicHttpBindingIDocumentosService(WebServiceFeature... features) {
return super.getPort(new QName("http://tempuri.org/", "BasicHttpBinding_IDocumentosService"), IDocumentosService.class, features);
}
private static URL __getWsdlLocation() {
if (DOCUMENTOSSERVICE_EXCEPTION!= null) {
throw DOCUMENTOSSERVICE_EXCEPTION;
}
return DOCUMENTOSSERVICE_WSDL_LOCATION;
}
- 问题在于,从本地窗口中的机器中,我们可以使WS正确响应此实现。但是,当我们进入Linux下的预生产环境时,我们无法连接。出现的痕迹是以下
2018-02-21 18:35:15,614 [Thread-22] [ WARN] (com.sun.xml.internal.ws.wspolicy.EffectiveAlternativeSelector:255) ->
WSP0075:政策主张 " {http://schemas.microsoft.com/ws/06/2004/policy/http} basicauthentication" 被评估为"未知"。2018-02-21 18:35:15,615 [Thread-22] [ 警告] (com.sun.xml.internal.ws.wspolicy.effectivealternativelector:255( -> WSP0019:在客户端选择的次优政策替代方案 健身"未知"。2018-02-21 18:35:15,666 [thread-22] [错误] (com.noaris.agis.util.documentoserviceutil:116( -> usernamejavax.xml.ws.security.auth.username 2018-02-21 18:35:15,667 [thread-22] [error](com.noaris.agis.util.documentosserviceutil:117( -> passwordjavax.xml.ws.security.auth.pasperword 2018-02-21 18:35:15,667 [thread-22] [error] [error](com.noaris.agis.util.util.documentoserviceutil:44( -> Llamada Al Servicio Getattachment Con Los Datos:593718000029818 2018-02-21 18:35:15,741 [thread-22] [错误] (com.noaris.agis.util.documentoserviceutil:63( -> http Transport 错误:javax.net.ssl.sslhandshakeexception: sun.security.Validator.Validatorexception:PKIX PATH建筑物失败: sun.security.provider.certpath.suncertpathbuilderexception:无法 查找目标目标2018-02-21的有效认证路径 18:35:15,742 [thread-22] [错误] (com.noaris.agis.screens.expedientes.detalleexpediente_documentacionvm:1040( ->错误inesperado durante la gertenci? com.noaris.agis.exception.businessException at com.noaris.agis.util.documentosserviceutil.getcomunicaciones(documentosserviceutil.java:65(at com.noaris.agis.screens.expedientes.detalleexpedeiente_documentacionvm $ documenservicEthread.run(detalleexpedeient_documente_documentacionvm.java:1028(
The certificates in the preproduction machines are well installed in the java carcets. Therefore the exception unable to find valid certification path to requested target, we can not understand why it is launched.
On the other hand, two warn "UNKNOWN" appear when it enters the DocumentService class. We think that maybe this may be because when we enter the wsdl we need to get credit in advance. In this case we do not know how to insert the username and password before calling the wsdl ... if necessary.
我们已经遇到了这个问题已有数周了。任何形式的帮助将不胜感激。问候,谢谢
我认为您的问题在此行中突出显示:sslhandshakeexception:sun.security.Validator.ValidatoreXception:PKIX PATH构建失败:Sun.Security.Cervider.CertPath.SuncertPathBuildErexception:无法找到有效的认证路径
在本地Windows机器上,您可以内置访问密钥存储。但是,从远程计算机看,该证书不可见。
要快速查看这是否是真的,请在该站点上放一个" hello.html"页面,然后检查任何浏览器'https://yourwebpage.com/hello.html'返回的证书。在返回您的预期证书之前,您的代码将无法正常工作。
hth,jim