xfire调用webservice[#document: null]问题

xfire 调用.net webservice的时候返回[#document: null]这个事怎么回事呀?

Client client = new Client(
new URL(
"http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl"));
HttpClientParams params = new HttpClientParams();
params.setParameter(HttpClientParams.USE_EXPECT_CONTINUE,
Boolean.FALSE);
params.setParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT,
(long) 9000);
client.setProperty(CommonsHttpMessageSender.HTTP_CLIENT_PARAMS,
params);
Object[] obj = (Object[]) client.invoke("getCountryCityByIp", new Object[] {
"125.64.15.45" });

 

 

返回的是org.apache.xerces.dom.DocumentImpl,你也可以强制转换为w3c的document。

java操作xml:

try {
            Client client = new Client(new URL("http://www.webxml.com.cn/webservices/ChinaTVprogramWebService.asmx?wsdl"));
            Object[] results = client.invoke("getTVchannelString",new Integer[]{2});
            System.out.println(results[0]);
            Document d = (Document)results[0];
            System.out.println(d.getFirstChild());
            NodeList nl =d.getElementsByTagName("getTVchannelStringResult");
            NodeList n2 = nl.item(0).getChildNodes();
            System.out.println(n2.getLength());
            for (int i=0;i<n2.getLength();i++){
                System.out.println(n2.item(i).getNodeName()+"::"+n2.item(i).getTextContent());
               
            }
          
     } catch (MalformedURLException e) {
            e.printStackTrace();
     } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
     }

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值