sách gpt4 ai đã đi

Các vấn đề với SAX

In lại 作者:行者123 更新时间:2023-12-01 16:01:01 28 4
mua khóa gpt4 Nike

我有下面的代码..

         System.setProperty("http.proxyHost","176.6.129.25") ;
System.setProperty("http.proxyPort", "8080") ;
Authenticator.setDefault(new MyAuthenticator());
//http://deadlock.netbeans.org/hudson/api/xml
*URL url = new URL("http://in8301782d:8080/api/xml");*
Document dom = new SAXReader().read(url);
for( Element job : (List)dom.getRootElement().elements("job")) {
System.out.println(String.format("Name:%s\tStatus:%s",
job.elementText("name"), job.elementText("color")));
}

如果我替换为http://deadlock.netbeans.org/hudson/api/xml,则此代码可以正常工作。 ,但它不适用于 http://in8301782d:8080/api/xml 。事实上,如果我在浏览器中输入相同的内容,它就可以工作。如果我用 IP 地址替换主机名,它也不起作用。

我遇到的异常如下。

*With in8301782d (machine name)* :

xception in thread "main" org.dom4j.DocumentException: http://in8301782d:8080/api/xml Nested exception: http://in8301782d:8080/api/xml
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.dom4j.io.SAXReader.read(SAXReader.java:291)
at com.sg.hudson.ci.Main.main(Main.java:140)
Nested exception:
java.io.FileNotFoundException: http://in8301782d:8080/api/xml
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1243)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.dom4j.io.SAXReader.read(SAXReader.java:291)
at com.sg.hudson.ci.Main.main(Main.java:140)

*With Ip (http://176.6.55.55:8080/api/xml):*

Exception in thread "main" org.dom4j.DocumentException: Server returned HTTP response code: 503 for URL: http://176.6.66.156:8080/api/xml Nested exception: Server returned HTTP response code: 503 for URL: http://176.6.66.156:8080/api/xml
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.dom4j.io.SAXReader.read(SAXReader.java:291)
at com.sg.hudson.ci.Main.main(Main.java:140)
Nested exception:
java.io.IOException: Server returned HTTP response code: 503 for URL: http://176.6.66.156:8080/api/xml
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.dom4j.io.SAXReader.read(SAXReader.java:291)
at com.sg.hudson.ci.Main.main(Main.java:140)

1 Câu trả lời

这似乎不是您的代码的问题。

在第一个异常中,SAX 告诉您它找不到 http://in8301782d:8080/api/xml - 无法到达此 URL。如果该 URL 在您的浏览器中有效,则代理设置可能有问题。

在第二个异常中,SAX 报告服务器返回不成功的 HTTP 状态代码 503,which (according to the HTTP specification) means :

The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay.

当然,位于此 URL 的应用程序也可能会出于某种非标准原因向您发送 HTTP 503。

关于java - SAX 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3924159/

28 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com