好的,所以我必须为 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);
最佳答案
net.webservicex.GeoIP@564809be
看来您正在打印对象的引用(net.webservicex.GeoIP
尚未覆盖toString
)。他们没有一些String getIP()
来获取IP吗?
关于java - SOAP 客户端对 JAVA 中给定 WSDL 的奇怪响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13786163/