1

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

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

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 文件中的端点是内部地址。这就是我连接不上的原因。我是否需要以某种方式将这些端点设置为我的代码中的其他内容???

有什么建议吗?谢谢。

4

2 回答 2

1

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");
于 2011-11-17T09:17:30.060 回答
0

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

于 2011-11-15T11:21:15.370 回答