0

i have used a sample wsdl in my java code. when i try to print the output it returns only the package name like:

com.holidaywebservice.holidayservice_v2.CountryCode@6b6478

This happens only when the output was a list.

Part of my code:

HolidayService2 hs1= new HolidayService2();

HolidayService2Soap hss1=  hs1.getHolidayService2Soap();

ArrayOfCountryCode acc = hss1.getCountriesAvailable();

system.out.println(acc.getCountryCode());

wsdl url:http://holidaywebservice.com/HolidayService_v2/HolidayService2.asmx?WSDL

Rahul Agarwal
  • 4,034
  • 7
  • 27
  • 51

1 Answers1

0

With this com.holidaywebservice.holidayservice_v2.CountryCode@6b6478 you're trying to print the ArrayOfCountryCode object. Your code instead should be:

package com.holidaywebservice.holidayservice_v2.clientsample;

import com.holidaywebservice.holidayservice_v2.*;

public class ClientSample {

    public static void main(String[] args) {
            //Create Web Service Client..."
            HolidayService2 service1 = new HolidayService2();
            //Create Web Service...
            HolidayService2HttpGet port1 = service1.getHolidayService2HttpGet();

            //call WS
            ArrayOfCountryCode acc =  port1.getCountriesAvailable();
            for(CountryCode cc : acc.getCountryCode()){
                System.out.println("Country code is: " + cc.getCode());
                System.out.println("Country code Description is: " + cc.getDescription());
            }
    }
}


Update Try just adding the below

for(CountryCode cc : acc.getCountryCode()){
    System.out.println("Country code is: " + cc.getCode());
    System.out.println("Country code Description is: " + cc.getDescription());
}


After the line ArrayOfCountryCode acc = hss1.getCountriesAvailable(); in your current code. But you see the gist of it, acc is an array of country codes.

JGlass
  • 1,427
  • 2
  • 12
  • 26