加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 01:26:55 所属栏目:安全 来源:网络整理
导读:xfire 调用.net webservice的时候返回[#document: null]这个事怎么回事呀? Client client = new Client( new URL( "http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl")); HttpClientParams params = new HttpClientParams(); par

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(); ???? }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读