我是 JAX-WS 的新手。我正在尝试访问公司内远程计算机上的 Web 服务。
我使用 wsimport 工具从我们内部网上的 WSDL 资源生成 JAVA 类。Java 文件已成功创建。
我尝试通过 SOAPUI 发送请求,得到有效响应。但是当我尝试运行我的代码时,它会抛出 Connection refused。
这是我的代码。
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);
后来我尝试添加这段代码,它仍然不起作用。
Authenticator.setDefault(new ProxyAuthenticator("fmsopsqa","fmsopsqa"));
System.setProperty("http.proxHost","sprdxmaws401.corp.net");
System.setProperty("http.proxyPort", "8081");
这就是我得到的
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)
服务端点链接似乎设置正确。
@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")