[WebService] XFire调用WEB Service失败,帮忙看看

lsunwing 2010-04-15
我调用用天气预报的Web Service总是调不通,各位帮忙看看呐!

代码如下:
接口:
public interface IWeatherWS {
public String[] getWeather(String theCityCode, String theUserID);
}

public class XfireWeatherWS
{

    public static void main(String[] args)
    {
        new XfireWeatherWS().getWeatherByCityName("北京");
    }
   
    private void getWeatherByCityName(String theCityName)
    {
        try
        {
            IWeatherWS weatherWS = null;
            Service serviceModel = new ObjectServiceFactory().create(com.linkage.xfire.weather.IWeatherWS.class);
            serviceModel.setProperty(CommonsHttpMessageSender.HTTP_PROXY_HOST, "代理名称");
            serviceModel.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PORT, "8080");
           
            XFire xfire = XFireFactory.newInstance().getXFire();
            XFireProxyFactory factory = new XFireProxyFactory(xfire);
           
            String serviceURL = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx";
            weatherWS = (IWeatherWS) factory.create(serviceModel, serviceURL);
           
            String[] result  = weatherWS.getWeather(theCityName,"");
            System.out.println(result.length);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}
?????????
错误信息:
- I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
- Retrying request
- java.net.ConnectException: Connection timed out: connect
org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Couldn't send message.
org.codehaus.xfire.fault.XFireFault: Couldn't send message.
at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:30)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
at org.codehaus.xfire.client.Client.invoke(Client.java:336)
at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
at $Proxy0.getWeather(Unknown Source)
at com.linkage.xfire.weather.XfireWeatherWS.getWeatherByCityName(XfireWeatherWS.java:36)
at com.linkage.xfire.weather.XfireWeatherWS.main(XfireWeatherWS.java:15)
yhailj 2010-04-15
这种问题拿来问. 一看就知道超时了.
没准你过几个小时再调用的时候又好了

国内的这些 Web Services 服务就是这样的
ahong1010 2010-06-11
连接超时,可以先在地址栏上访问下url看能不能访问!服务端程序是否写正确了!
springluo 2010-07-04
你现在浏览器中访问一下ws地址是否正确。
我认为很有可能是
String serviceURL = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx"; 不正确
Global site tag (gtag.js) - Google Analytics