做webservice客户端的时候一直报下面这个错误:
com.sun.xml.internal.ws.client.ClientTransportException: HTTP 传输错误: java.net.ConnectException: Connection refused: connect
在stackoverflow上面找到了解决办法,https://stackoverflow.com/questions/15036155/jax-ws-com-sun-xml-internal-ws-client-clienttransportexception-http-transport-e。
指向的URL错误,覆盖BindingProvider.ENDPOINT_ADDRESS_PROPERTY就可以了:
String wsdlURL = "xxxx"; //要请求的URL地址
...
MyService myService = serviceWebClient.getPort(MyService.class); BindingProvider bindingProvider = (BindingProvider) myService; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsdlURL);