gpt4 book ai didi

java - Java代码无法访问Web Service,但在Chrome中可以正常看到其wsdl

转载 作者:行者123 更新时间:2023-12-01 22:47:52 25 4
gpt4 key购买 nike

大家!

我遇到了一个很奇怪的问题。我在 Netbeans 中编写了一个 Web 服务示例。在 Netbeans IDE 中,Web 服务客户端和 Web 服务运行流畅,只是有点慢。但部署到Tomcat 7.0后,客户端无法正常访问Web服务。

wsdl的url是http://221.207.220.12:7001/InterWebService/InterService.wsdl?wsdl,可以通过Chrome看到。

以下是异常信息:

Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException:      HTTP transport error: java.net.ConnectException: Connection timed out: connect
at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:117)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:208)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:130)
at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:95)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:1121)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:1035)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:1004)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:862)
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:448)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:178)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:93)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147)
at com.sun.proxy.$Proxy32.news(Unknown Source)
at Main.news(Main.java:19)
at Main.main(Main.java:13)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1167)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1146)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:997)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:931)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1281)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1256)
at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:104)
... 15 more
Java Result: 1
BUILD SUCCESSFUL (total time: 23 seconds)*

寻求帮助!提前致谢。

最佳答案

我也遇到过类似的问题,并找到了根本原因如下:

在调查问题的根本原因时,发现 WSDL 文件中“wsdl:port”元素的“soap:address”引用的 url 与调用 Web 服务的 url 不匹配。根据 SOAP 规范,这是不正确的。

在我们的环境中,“soap:address”指的是 wsdl 文件中的“反向代理”url(即“xxx.com:9040/service.asmx”),这不是我们尝试访问 Ace 服务的实际 url (即“xxx.com/service.asmx”)

关于java - Java代码无法访问Web Service,但在Chrome中可以正常看到其wsdl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25081172/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com