“连接超时” (无法发送消息)针对 SOAP 请求(但服务未关闭)

发布于 2024-12-16 10:25:18 字数 4927 浏览 3 评论 0原文

我在向另一家公司的 Web 服务发出 SOAP 请求时收到“连接超时”消息。我使用 wsimport 从 wsdl 创建 Java 类。我不认为这对其他公司来说是个问题,因为他们为我提供了一个小应用程序,它使用网络服务来快速测试我自己编码时应该得到什么结果,而且效果很好。

在下面的示例中,我试图获取有关学校“员工”的数据...

OtherCompanyWebService ws = new OtherCompanyWebService();
OtherCompanyWebServicePortType port = ws.getOtherCompanyWebServiceHttpSoap11Endpoint();
ServiceRequest serviceRequest = makeMyServiceRequest();
Staff staff = port.getStaffData(serviceRequest).getStaff().getValue();

在代码的最后一行,我收到以下错误...

javax.xml.ws.soap.SOAPFaultException: Could not send Message.
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:199)
        at $Proxy52.getStaffData(Unknown Source)
        at uk.co.txttools.rm.service.RmServiceImpl.runRmJob(RmServiceImpl.java:208)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy12.runRmJob(Unknown Source)
        at uk.co.txttools.rm.quartz.RmJob.execute(RmJob.java:41)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: org.apache.cxf.interceptor.Fault: Could not send Message.
        at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
        ... 16 more
Caused by: java.net.ConnectException: Connection timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:158)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
        at sun.net.www.http.HttpClient.New(HttpClient.java:306)
        at sun.net.www.http.HttpClient.New(HttpClient.java:323)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:975)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:916)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:841)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1019)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1834)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1792)
        at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42)
        at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1852)
        at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
        at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:593)
        at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)

编辑 1: 看来端点wsdl 文件中是内部地址。这就是我无法连接的原因。我是否需要以某种方式将这些端点设置为代码中的其他内容???

有什么建议吗?谢谢。

I'm getting 'Connection timed out' on a SOAP request to another company's webservice. I have used wsimport to create the Java classes from the wsdl. I don't think its a problem on the other companies end, because they have provided me with a little app which uses the webservice to quickly test what results I should get when I code it myself, and that works fine.

In the example below I am trying to get data about 'Staff' at a school ...

OtherCompanyWebService ws = new OtherCompanyWebService();
OtherCompanyWebServicePortType port = ws.getOtherCompanyWebServiceHttpSoap11Endpoint();
ServiceRequest serviceRequest = makeMyServiceRequest();
Staff staff = port.getStaffData(serviceRequest).getStaff().getValue();

On the final line of code, I get the following error ...

javax.xml.ws.soap.SOAPFaultException: Could not send Message.
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:199)
        at $Proxy52.getStaffData(Unknown Source)
        at uk.co.txttools.rm.service.RmServiceImpl.runRmJob(RmServiceImpl.java:208)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy12.runRmJob(Unknown Source)
        at uk.co.txttools.rm.quartz.RmJob.execute(RmJob.java:41)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: org.apache.cxf.interceptor.Fault: Could not send Message.
        at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
        ... 16 more
Caused by: java.net.ConnectException: Connection timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:158)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
        at sun.net.www.http.HttpClient.New(HttpClient.java:306)
        at sun.net.www.http.HttpClient.New(HttpClient.java:323)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:975)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:916)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:841)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1019)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1834)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1792)
        at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42)
        at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1852)
        at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
        at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:593)
        at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)

Edit 1: it appears that the endpoints in the wsdl file are internal addresses. This is why I cant connect. Do I need to set these endpoints to something else in my code somehow???

Any advice? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橘和柠 2024-12-23 10:25:18

就像我在问题编辑中所说的那样,wsdl 中的端点需要更改(尽管这对我来说听起来很疯狂)。这可以按如下方式完成...

    BindingProvider bindingProvider = (BindingProvider) port;
    bindingProvider.getRequestContext().put(
          BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
          "https://blah/blah/blah");

Like I said in the edit to the question, the endpoints in the wsdl need changing (even though this sounds crazy to me). This can be done as follows ...

    BindingProvider bindingProvider = (BindingProvider) port;
    bindingProvider.getRequestContext().put(
          BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
          "https://blah/blah/blah");
通知家属抬走 2024-12-23 10:25:18

其实我也遇到过类似的问题; wsdl 可以从公司内部的任何 whr 访问(通过浏览器)。但是在调用 web 服务(通过客户端代码)时会抛出超时异常。在这种情况下,我所做的就是提出一个 CR,使我的系统位于特定域之外,并打开系统上的端口,以便它可以使用 Web 服务客户端发布请求。您可以咨询您的(基础设施管理团队,他们基本上是安装软件解决系统相关问题)

另一件事是,大多数公司都使用基于微软的代理。因此,如果您可以使用代理双通代码(基于 NTLM)。并使用它来测试 perpous,但这将是一个彻底的代码,因为任何方式代理双通代码都不应该进入生产

Actually I have faced similar issue; The wsdl can be accessible from any whr inside the company(Through browser).But while calling webservice(through client code) throws time out Exception. In that case what i did ,i raised a CR for making my system outside the particular domain and open the port on the system so that it would post the request using webservice client. You can consult to your (infrastructure management team who are basically installing s/w solving system related issue)

One more thing is that most of the company use microsoft based proxy. So if u can use proxy bipassing code (NTLM based) . and use that for testing perpous but that would be a through away code because any way proxy bipassing code should not go to production

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文