views:

26

answers:

2

This is part of a lab exercise for a course I'm doing, it's not assessable, just a learning exercise. Not sure why but the tut didn't go through it, so I just went through it at home but I'm stuck on the last part.

I'm trying to write a java WSDL client to access http://www.nanonull.com/TimeService/TimeService.asmx?WSDL - I should input UTC+10 to display the current time. Below is the code that I have written:

package time;
class Client {
 public static void main(String args[]){
        TimeService service = new TimeService();
        TimeServiceSoap port= service.getTimeServiceSoap();
        String result = port.GetTimeZoneTime("UTC+10");
        System.out.println("Time is "+result);
 }

}

When I try and compile the code I get the following error:

C:\Program Files\Java\jdk1.6.0_22\bin>javac -d . "c:\Program Files\Java\jdk1.6.0
_22\bin\time\Client.java"
c:\Program Files\Java\jdk1.6.0_22\bin\time\Client.java:13: cannot find symbol
symbol  : method GetTimeZoneTimeResponse(java.lang.String)
location: interface time.TimeServiceSoap
        String result = port.GetTimeZoneTime("UTC+10");
                            ^
1 error

Any thoughts on what I'm doing wrong?

+2  A: 

Did you mean

String result = port.getTimeZoneTime("UTC+10");

with a lowercase g? Java method names are case-sensitive, so it won't recognize the method if you get its letter casing wrong. As per both WSDL's TimeServiceSoap documentation and Java naming conventions, method names are in camel case beginning with a lowercase letter.

BoltClock
Thank you that worked. When I ran wsimport I could only find references to a G not g.
homiejoe
+1  A: 

What does your TimeServiceSoap look like?

Perhaps you meant to use getTimeZoneTime() (starting with a lower case letter)?

Yuval A