日期:2014-05-17  浏览次数:20683 次

x-fire调用webservice Exception
Java code
public static void main(String[] args) {
        // TODO Auto-generated method stub
        try {
            Client client = new Client(new URL("http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl"));
            Object[] results = client.invoke("getSupportCityString",new Integer[]{3113});
            System.out.println(results[0]);
            Document document = (Document) results[0];
            System.out.println(document.getFirstChild());
            NodeList l1 =document.getElementsByTagName("string");
            for (int i = 0; i < l1.getLength(); i++) {
                NodeList n2 = l1.item(i).getChildNodes();
                for (int j = 0; j < n2.getLength(); j++) {
                    System.out.println(n2.item(i).getTextContent());
                }
            }

        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    
    }

运行后报错:

org.codehaus.xfire.fault.XFireFault: 服务器无法处理请求。 ---> 值不能为空。
参数名: input
at org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31)
at org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28)
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:111)
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Client.onReceive(Client.java:406)
at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
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.Client.invoke(Client.java:368)
at TestCity.main(TestCity.java:18)


------解决方案--------------------
TestCity.main(TestCity.java:18) 看看是不是你那个参数为空了?