简体   繁体   English

如何在不使用Java下载到本地计算机的情况下使用HTTPS wsdl文件

[英]How to use an HTTPS wsdl file without downloading to local computer in java

I just implemented my first webservice (client). 我刚刚实现了我的第一个Web服务(客户端)。 The URL is HTTPS. URL是HTTPS。 I tried to use the URL directly but i could not. 我试图直接使用URL,但我不能。 So i downloaded the WSDL file and everything worked fine. 所以我下载了WSDL文件,一切正常。 Now the problem is that when service definition changes i will not know because the code that i wrote is based on the local WSDL i saved. 现在的问题是,当服务定义更改时,我将不知道,因为我编写的代码基于我保存的本地WSDL。 So back to square one. 回到正题。 Is it possible to use HTTPS URL directly without downloading it. 是否可以不下载而直接使用HTTPS URL。
The exceptions i got while trying to implement the webservice using the URL are: 我在尝试使用URL实施Web服务时遇到的异常是:

Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:151)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:101)
at javax.xml.ws.Service.<init>(Unknown Source)
at org.tempuri.Service.<init>(Service.java:43)
at org.tempuri.ServiceSoap_ServiceSoap_Client.main(ServiceSoap_ServiceSoap_Client.java:65)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:100)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
... 4 more

Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'https myipaddress service.asmx?WSDL'.: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2198)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2390)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2422)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:263)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:206)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98)
... 6 more

Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2188)
... 11 more

Caused by: java.security.cert.CertificateException: No subject alternative names present
at sun.security.util.HostnameChecker.matchIP(Unknown Source)
at sun.security.util.HostnameChecker.match(Unknown Source)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkIdentity(Unknown Source)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)

Please help. 请帮忙。 Thanks in advance. 提前致谢。

The simple answer is yes it is possible to use HTTPS to retrieve the WSDL. 简单的答案是,可以使用HTTPS检索WSDL。

The "No subject alternative names present" is Java's obscure way of telling you that there is a mismatch between the hostname of the URL you are using, and the Common Name (CN) in the hosts Certificate. “不存在主题备用名称”是Java晦涩的告诉您正在使用的URL的主机名与主机证书中的公用名(CN)不匹配的方式。

The right solution is to either use the hostname that matches the certificate, or get a new certificate issued with the proper hostnames in it. 正确的解决方案是要么使用与证书匹配的主机名,要么获得带有正确主机名的新证书。

There is a work around described in this similar question . 类似问题中有解决方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Java 中 WSDL 文件中的串行器? - How to use Serializer from WSDL file in Java? Java和HTTPS url连接,无需下载证书 - Java and HTTPS url connection without downloading certificate 使用wsdl文件的Java客户端应用程序(本地) - Java client application using wsdl file (local) 通过Java通过https下载文件 - Downloading a file over https over java 如何在没有wsdl的情况下使用SoapUi - how to use SoapUi without wsdl Java中基于HTTPS的WSDL - WSDL over HTTPS in Java 从 Azure Blob 存储读取和写入 excel 文件,无需将其下载到 Java 中的本地文件 - Read and write an excel file from Azure Blob Storage without downloading it to local file in Java 如何在java中使用本地HTTPS URL? - How do I use a local HTTPS URL in java? 如何在Java控制台(无UI)中显示下载文件的进度百分比? - How to show percentage progress of a downloading file in java console(without UI)? 如何在使用带有 Selenium Java 的 Chrome 驱动程序 79 下载 .xml 文件时隐藏警告“此类文件可能会损害您的计算机” - How to hide the warning "This type of file can harm your computer" while downloading .xml file using Chrome Chromedriver 79 with Selenium Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM