简体   繁体   English

JAX WS com.sun.xml.internal.ws.client.ClientTransportException:HTTP 传输错误:java.net.ConnectException:连接被拒绝

[英]JAX WS com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused

I am new to JAX-WS.我是 JAX-WS 的新手。 I am trying to access a web service on a remote machine within the company.我正在尝试访问公司内远程机器上的 Web 服务。

I used wsimport tool to generate JAVA classes from the WSDL resource which is present on our intranet.我使用 wsimport 工具从我们内部网上的 WSDL 资源生成 JAVA 类。 Java files have been successfully created.已成功创建 Java 文件。

I tried sending a request through SOAPUI, I get a valid response.我尝试通过 SOAPUI 发送请求,得到有效响应。 But when I try to run my code it throws Connection refused.但是当我尝试运行我的代码时,它抛出连接被拒绝。

Here is my code.这是我的代码。

URL url = new URL("https://xmattersqa.com/api/services/xmatters-4.1.7?wsdl");

QName qname = new QName("http://www.xmatters.com/webservices/schema#4.1.7", "xmatters-   4.1.7");

FindWhoIsOnDuty f = new FindWhoIsOnDuty();  
Xmatters417 cdoubleprime = new Xmatters417(url,qname);

Xmatters417PortType port = cdoubleprime.getXmatters417SOAP11PortHttp();

FindWhoIsOnDutyReturn fresponse = port.findWhoIsOnDuty("fmsopsqa","fmsopsqa", "", "", "",   "Default Company", "Test Grp 1","23/02/2013 0:00:00 AM", "24/02/2013 0:00:00 AM", false);

Later I tried adding this piece of code , and it still doesnt work.后来我尝试添加这段代码,它仍然不起作用。

Authenticator.setDefault(new ProxyAuthenticator("fmsopsqa","fmsopsqa"));
System.setProperty("http.proxHost","sprdxmaws401.corp.net");
System.setProperty("http.proxyPort", "8081");

This is what I get这就是我得到的

com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error:    java.net.ConnectException: Connection refused
at      com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:121)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:142)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83)
at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:211)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:124)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at $Proxy32.findWhoIsOnDuty(Unknown Source)
at FindDuty.main(FindDuty.java:76)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:227)
at sun.net.www.http.HttpClient.New(HttpClient.java:300)
at sun.net.www.http.HttpClient.New(HttpClient.java:317)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:949)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1014)
at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:109)

Service Endpoint links seem to be set correctly.服务端点链接似乎设置正确。

@WebServiceClient(name = "xmatters-4.1.7", targetNamespace = "http://www.xmatters.com/webservices/schema#4.1.7", wsdlLocation = "https://xmattersqa.com/api/services/xmatters-4.1.7?wsdl")

I guess this is way too late but maybe this solution will help others facing the same issue.我想这太晚了,但也许这个解决方案会帮助其他面临同样问题的人。 I just ran into the same problem and found that my proxy-stub-object was calling another URL than I had given to the service object.我刚刚遇到了同样的问题,发现我的代理存根对象正在调用另一个 URL,而不是我提供给服务对象的 URL。

java.net.URL wsdlURL = new URL("http://myServiceHost.com/online/myService?wsdl");
Service serviceWebClient = new ServiceWebClient(wsdlURL, new QName("my/namespace", "MyServiceName"));

My debugger showed me then that my service did not try to access the given URL but an internal IP-Address that was inside the projected wsdl on this URL under the service tag.我的调试器然后向我展示了我的服务没有尝试访问给定的 URL,而是一个内部 IP 地址,该地址位于服务标签下此 URL 上的投影 wsdl 内。

<service name="MyServiceName">
  <port name="MyServicePort" binding="tns:MyServiceBindingBinding">
    <soap:address location="http://192.168.3.20:9443/online/myService/"/>
  </port>
</service>

so the stub pointed to the endpoint at 192.168.3.20 but my service was not on the same machine and therefore it could obiously not be reached.所以存根指向端点 192.168.3.20 但我的服务不在同一台机器上,因此显然无法访问它。 In order to fix that you have to correct the URL on the stub like this为了解决这个问题,您必须像这样更正存根上的 URL

MyService myService = serviceWebClient.getPort(MyService.class);
BindingProvider bindingProvider = (BindingProvider) myService;
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsdlURL.toString());

this fixed the issue for me这为我解决了问题

除了防火墙白名单作为可能的原因之外,如果您收到“HTTP 状态代码 404:已处理”,它甚至可能没有该服务方法可用。

This might be dumb, I have a situation where I defined two port biding on get and update operation, acutally they meant the same thing.这可能很愚蠢,我有一种情况,我在 get 和 update 操作上定义了两个端口竞标,实际上它们的意思是一样的。 After removing duplicate, issue fixed.删除重复后,问题已解决。 Just in case it may help any one.以防万一它可以帮助任何人。

As this is the top search result, when searching for this error message.由于这是搜索此错误消息时的顶级搜索结果。 You'll also get the "connection refused" error message, if you're specifying a wrong port number.如果您指定了错误的端口号,您还会收到“连接被拒绝”错误消息。 For me, it was as simple as that.对我来说,就是这么简单。 Double check to make sure.仔细检查以确保。

暂无
暂无

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

相关问题 com.sun.xml.internal.ws.client.ClientTransportException:HTTP传输错误:java.net.SocketException:连接重置 - com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.SocketException: Connection reset 线程“ main” com.sun.xml.internal.ws.client.ClientTransportException中的异常:服务器发送了HTTP状态代码502:代理错误 - Exception in thread “main” com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 502: Proxy Error com.sun.xml.ws.client.ClientTransportException:HTTP传输错误:java.lang.ClassCastException - com.sun.xml.ws.client.ClientTransportException: HTTP transport error: java.lang.ClassCastException 连接到 web 服务导致 com.sun.xml.internal.ws.client.ClientTransportException:服务器发送 HTTP 状态码 200 - Connecting to webservice results in com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 200: OK 导入com.sun.xml.internal.ws.client.ClientTransportException,无法读取此导入 - import com.sun.xml.internal.ws.client.ClientTransportException, can't read this import HTTP传输错误:java.net.ConnectException:连接超时:在Soap ws客户端中连接 - HTTP transport error: java.net.ConnectException: Connection timed out: connect in Soap ws client Glassfish抛出com.sun.xml.ws.client.ClientTransportException:服务器发送了HTTP状态代码500:内部服务器错误 - Glassfish throws com.sun.xml.ws.client.ClientTransportException: The server sent HTTP status code 500: Internal Server Error com.sun.jersey.api.client.ClientHandlerException:java.net.ConnectException:连接被拒绝:在 Spring Boot 中连接 - com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect in Spring Boot com.sun.xml.ws.client.ClientTransportException:请求需要HTTP身份验证:未经授权 - com.sun.xml.ws.client.ClientTransportException: request requires HTTP authentication: Unauthorized 线程“main”中的异常 com.sun.jersey.api.client.ClientHandlerException:java.net.ConnectException:连接被拒绝:连接 - Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM