好的,所以我必须为JAVA中的给定WSDL创建一个SOAP客户端,如标题所示。 现在我使用NetBeans构建它,问题是,当我运行它并输入我想要的IP时,我得到以下响应 “net.webservicex.GeoIP@564809be”
我在他们的站点测试了WSDL,对于相同的IP,我得到以下
<GeoIP xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.webservicex.net/">
<ReturnCode>1</ReturnCode>
<IP>178.128.33.188</IP>
<ReturnCodeDetails>Success</ReturnCodeDetails>
<CountryName>Greece</CountryName>
<CountryCode>GRC</CountryCode>
</GeoIP>
任何想法?虽然我必须“解码”消息才能正常打印出来? 提前谢谢
这是客户端的代码
public static void main(String[] args) {
try {
System.out.println("Enter the IP Adress");
InputStreamReader converter = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(converter);
String ipad = in.readLine();
System.out.println(getGeoIP(ipad));
} catch (IOException ex) {
Logger.getLogger(Geoipad.class.getName()).log(Level.SEVERE, null, ex);
}
}
private static GeoIP getGeoIP(java.lang.String ipAddress) {
net.webservicex.GeoIPService service = new net.webservicex.GeoIPService();
net.webservicex.GeoIPServiceSoap port = service.getGeoIPServiceSoap();
return port.getGeoIP(ipAddress);
答案 0 :(得分:2)
net.webservicex.GeoIP@564809be
您似乎正在打印对象的引用(net.webservicex.GeoIP
未覆盖toString
)。难道他们没有String getIP()
来获取IP吗?
答案 1 :(得分:0)
以下作品
GeoIPService ipService = new GeoIPService();
GeoIPServiceSoap geoIPServiceSoap = ipService.getGeoIPServiceSoap();
GeoIP geoIp = geoIPServiceSoap.getGeoIP("10.34.55.1");
System.out.println(geoIp.getCountryName());