简体   繁体   中英

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. 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"

I tested the WSDL at their site and for the same IP i get the following

<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 ). Don't they have some String getIP() to get the 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());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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