简体   繁体   English

SOAP客户端对JAVA中给定WSDL的响应奇怪

[英]Strange response from a SOAP Client for a given WSDL in JAVA

Ok so i have to make a SOAP Client for a given WSDL in JAVA as the title says. 好的,所以我必须为JAVA中的给定WSDL创建一个SOAP客户端,正如标题所说。 Now i build it with NetBeans and the issue is that when i run it and put in the IP that i want i get the following response "net.webservicex.GeoIP@564809be" 现在我使用NetBeans构建它,问题是,当我运行它并输入我想要的IP时,我得到以下响应“net.webservicex.GeoIP@564809be”

I tested the WSDL at their site and for the same IP i get the following 我在他们的站点测试了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>

Any ideas?? 有任何想法吗?? While i have to "decode" the message in order to be printed out normally? 虽然我必须“解码”消息才能正常打印出来? THanks in advance 提前致谢

Here's the code of the client 这是客户端的代码

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
It seems you are printing the object's reference (the net.webservicex.GeoIP has not overriden toString ). 看来你正在打印对象的引用( net.webservicex.GeoIP没有覆盖toString )。 Don't they have some String getIP() to get the IP? 他们不是有一些String getIP()来获取IP吗?

the following works 以下作品

GeoIPService ipService = new GeoIPService();
GeoIPServiceSoap geoIPServiceSoap = ipService.getGeoIPServiceSoap();
GeoIP geoIp = geoIPServiceSoap.getGeoIP("10.34.55.1");
System.out.println(geoIp.getCountryName());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM