日期:2014-05-18  浏览次数:20649 次

xfire调用webservice返回的结果如何取到呀,现在调用 有问题吗?
xfire调用webservice返回的结果如何取到呀,现在调用 有问题吗?
try {
Client c = new Client(new URL("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl"));
Object[] params = new Object[2];
params[0] = "1.202.90.134";
Object[] results = c.invoke("getCountryCityByIp",params);
Document d = (Document)results[0];
System.out.println(d.getNodeValue());
System.out.println(results[0]);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

------解决方案--------------------
public static void main(String[] args) {
String url="http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx";
String soapPre="http://WebXml.com.cn/"; 
 try{
    Service service=new Service();
    Call call=(Call)service.createCall();            
            call.setTargetEndpointAddress(new java.net.URL(url));       
            call.setOperationName(new QName(soapPre,"getCountryCityByIp")); 
            call.addParameter(new QName(soapPre,"theIpAddress"), org.apache.axis.encoding.XMLType.XSD_STRING,
                    javax.xml.rpc.ParameterMode.IN);
            call.setReturnType(new QName(soapPre,"getCountryCityByIp"),Vector.class);    
            call.setUseSOAPAction(true);
            call.setSOAPActionURI(soapPre + "getCountryCityByIp");    
                        
            Vector<String> v=(Vector<String>)call.invoke(new Object[]{"1.202.90.134"});
            System.out.println("***************");
            for(int i=0;i<v.size();i++)
            {
                System.out.println(v.get(i));
            }     
          &