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