【问题标题】:Not response webservice. Not found valid certification不响应网络服务。未找到有效证书
【发布时间】:2018-02-23 13:05:38
【问题描述】:

我们正在用 java 开发一个应用程序,并且从几周前开始,我们遇到了一个我们无法解决的问题。它是对 Web 服务的调用,以获取一系列带有证书的数据。我们已按照以下步骤创建工件和后续调用

1.我们在windows cmd wsimport -keep https: //xxx/xxx/xxx.svc中启动wsimport命令SingleWsdl -s C:\Users\mvelasco\Documents\xx\xxxx\src\main\java -Xauthfile C:\Users\mvelasco\authwsdl.txt 生成一系列具有ws和datacontract结构的类。 enter image description here

  1. 我们已导入证书

keytool -importcert -keystore "C:\Program Files\java\jdk1.7.0_60\jre\lib\security\cacerts" -file -alias x

  1. 我们用下面的ws调用方法创建了一个类

    私有静态无效 llamadaAlServicio() { IDocumentosService 端口 = (new DocumentosService()) .getBasicHttpBindingIDocumentosService(); 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");
    

    }

DocumentosService 类由 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;
}
  1. 问题是,我们的机器在本地窗口中让 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}基本身份验证" 被评估为“未知”。 2018-02-21 18:35:15,615 [线程 22] [ 警告] (com.sun.xml.internal.ws.wspolicy.EffectiveAlternativeSelector:255) -> WSP0019:在客户端选择了次优策略替代方案 与健身“未知”。 2018-02-21 18:35:15,666 [线程 22] [错误] (com.noaris.agis.util.DocumentosServiceUtil:116)-> 用户名javax.xml.ws.security.auth.username 2018-02-21 18:35:15,667 [线程 22] [错误] (com.noaris.agis.util.DocumentosServiceUtil:117) -> Passwordjavax.xml.ws.security.auth.password 2018-02-21 18:35:15,667 [Thread-22] [ERROR] (com.noaris.agis.util.DocumentosServiceUtil:44) -> Llamada al servicio GetAttachment con los datos: 593718000029818 2018-02-21 18:35:15,741 [线程 22] [错误] (com.noaris.agis.util.DocumentosServiceUtil:63) -> HTTP 传输 错误:javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException:PKIX 路径构建失败: sun.security.provider.certpath.SunCertPathBuilderException:无法 找到请求目标的有效认证路径 2018-02-21 18:35:15,742 [线程 22] [错误] (com.noaris.agis.screens.expedientes.DetelleExpediente_DocumentacionVM:1040) -> Error inesperado durante la obtenci?n de datos del servicio DocumentosService para el expediente593718000029818 com.noaris.agis.exception.BusinessException 在 com.noaris.agis.util.DocumentosServiceUtil.getComunicaciones(DocumentosServiceUtil.java:65)at com.noaris.agis.screens.expedientes.DetalleExpediente_DocumentacionVM$DocumentosServiceThread.run(DetalleExpediente_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.

我们已经被这个问题困扰了好几个星期了。任何形式的帮助将不胜感激。问候和谢谢你

【问题讨论】:

    标签: java web-services wsimport


    【解决方案1】:

    我认为您的问题在这一行中突出显示: SSLHandshakeException:sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径

    在您的本地 Windows 计算机上,您具有对密钥存储的内置访问权限。但是,在远程机器上,这个证书是不可见的。

    要快速查看是否属实,请在该站点上放置一个“hello.html”页面,并在任何浏览器中检查“https://yourwebpage.com/hello.html”返回的证书。在返回您预期的证书之前,您的代码将无法正常工作。

    HTH,吉姆

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-01
      • 2018-02-21
      • 2010-11-15
      相关资源
      最近更新 更多