以前,我们在我们的应用有以下代码,并用于获取所需的数据。 我们只是用通过形成通过将用户名,密码和搜索参数(DEA号)的Web服务的URL来读取所需的字段。 相同的URL(包括参数)也可以从浏览器直接打到看到的结果:
{ DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
System.setProperty("http.proxyHost", getProxyHost());
System.setProperty("http.proxyPort", getProxyPort());
System.out.println("Before URL formation");
URL url = new URL(
"http://www.deanumber.com/Websvc/deaWebsvc.asmx/GetQuery?UserName=" + getDeaUsername() + "&Password=" + getDeaPassword() + "&DEA=" +
deaNumber +
"&BAC=&BASC=&ExpirationDate=&Company=&Zip=&State=&PI=&MaxRows=");
System.out.println("After URL formation");
System.out.println("URL formed is: "+url);
Document document = null;
try {
System.out.println("toExternalForm");
String strURL = url.toExternalForm();
System.out.println("toExternalForm done: "+strURL);
**document = parser.parse(strURL);** //This is causing exception
}
catch (SAXParseException spe)
{ System.out.println("Inside SAXParseException");
spe.printStackTrace();
}
}
现在,网络服务的网址已经得到了从http变成https用的东西一样休息。 新的URL也工作从浏览器。 此外,即使我在浏览器中输入http URL,它会自动重定向到HTTPS和显示数据。 然而,上面的代码不会做同样的,它给了以下异常:java.net.ProtocolException:不支持的协议:https'时
于是,我改变了在URL中使用https代码,但现在一个新的异常来了 - 的java.net.UnknownHostException。 从控制台日志,我可以看到,除了在==> 文件= parser.parse(strURL)的到来。 在这里,分析器为的DocumentBuilder对象的引用变量作为可以从上面的代码中看到。 我粘贴完整的堆栈跟踪之下。
对于完整的UnknownHostException堆栈跟踪:
{java.net.UnknownHostException: www.deanumber.com
[2017-23-28 08:23, 0]ERROR[[ACTIVE] ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'](DeaFetcher.java:123) - Exception in DeaFetcher.getDeaFromUrl java.net.UnknownHostException: www.deanumber.com
at java.net.InetAddress.getAllByName0(InetAddress.java:1250)
at java.net.InetAddress.getAllByName(InetAddress.java:1162)
at java.net.InetAddress.getAllByName(InetAddress.java:1098)
at weblogic.net.http.HttpsClient.openServer(HttpsClient.java:265)
at weblogic.net.http.HttpsClient.openServer(HttpsClient.java:350)
at weblogic.net.http.HttpsClient.New(HttpsClient.java:553)
at weblogic.net.http.HttpsURLConnection.getHttpClient(HttpsURLConnection.java:332)
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:711)
at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:643)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:189)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:812)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
at weblogic.xml.jaxp.RegistryDocumentBuilder.parse(RegistryDocumentBuilder.java:163)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:177)
at com.company.project.service.DeaFetcher.fetchDeaFromUrl(DeaFetcher.java:358)
at com.company.project.service.DeaFetcher.fetchDeas(DeaFetcher.java:330)
at com.company.project.service.DeaFetcher.fetchDeas(DeaFetcher.java:239)
at com.company.project.service.DeaFetcher.fetchDeaMastersList(DeaFetcher.java:46)
at com.company.project.service.DeaFetcher$$FastClassByCGLIB$$8f6b7575.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:695)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:630)
at com.company.project.service.DeaFetcher$$EnhancerByCGLIB$$a5bf2c5a.fetchDeaMastersList(<generated>)
at com.company.project.web.MainFormController.onSubmit(EntryFormController.java:137)
at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:250)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:857)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:475)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:440)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:751)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3432)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
}