java HTTP 传输错误:从 Glassfish 访问 Web 服务时连接被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33048956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 21:07:31  来源:igfitidea点击:

HTTP transport error: Connection refused when accessing web service from Glassfish

javajax-wsglassfish-4

提问by Rodion Nehoroshev

I have two applications running on Glassfish 4.1 server: one that provides jax-ws webservice, and other that uses it. Everything is fine as long as i use localhostor 127.0.0.1as endpoint in client app. But when i try to install webservice on remote machine and access it, i receive an error in client app: com.sun.xml.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect

我有两个应用程序在 Glassfish 4.1 服务器上运行:一个提供 jax-ws webservice,另一个使用它。只要我在客户端应用程序中使用localhost127.0.0.1作为端点,一切都很好。但是当我尝试在远程机器上安装 webservice 并访问它时,我在客户端应用程序中收到一个错误: com.sun.xml.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect

However, i canaccess remote wsdl from browser/SoapUI/Netbeans. Service port binding section of wsdl contains valid host:port.

但是,我可以从浏览器/SoapUI/Netbeans 访问远程 wsdl。wsdl 的服务端口绑定部分包含有效的主机:端口。

What i tried to do:

我试图做的:

  • Setting endpoint in client app using

    (BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
    
  • Redo jax-ws import from remote machine, so now even in local wsdl i have remote hostname;
  • Changed inject annotation to @WebServiceRef(wsdlLocation = "http://remotehost:remoteport/svc/port?wsdl")
  • Checked that glassfish listener is configured to IP 0.0.0.0
  • 使用在客户端应用程序中设置端点

    (BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
    
  • 从远程机器重做 jax-ws 导入,所以现在即使在本地 wsdl 中我也有远程主机名;
  • 将注入注释更改为 @WebServiceRef(wsdlLocation = "http://remotehost:remoteport/svc/port?wsdl")
  • 检查 glassfish 侦听器是否配置为 IP 0.0.0.0

So far, nothing helps. Furthermore, i experiencing same behaviour when i simply change endpoint from localhostto actual host name or IP of this very same machine.

到目前为止,没有任何帮助。此外,当我简单地将端点从localhost同一台机器的实际主机名或 IP更改时,我遇到了相同的行为。

Here's the exception log (partial):

这是异常日志(部分):

com.sun.xml.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect
at com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:131)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:223)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:145)
at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:139)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:136)
at com.sun.enterprise.security.webservices.ClientSecurityPipe.processSecureRequest(ClientSecurityPipe.java:198)
at com.sun.enterprise.security.webservices.ClientSecurityPipe.process(ClientSecurityPipe.java:186)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:119)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
at com.sun.xml.ws.client.Stub.process(Stub.java:463)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:191)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:92)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:161)
at com.sun.proxy.$Proxy386.processRequest(Unknown Source)

Any help would be appreciated!

任何帮助,将不胜感激!

回答by Rodion Nehoroshev

My fault, turned out that problem was caused by incorrect proxy settings in glassfish JVM options.

我的错,原来这个问题是由 glassfish JVM 选项中的不正确代理设置引起的。