简体   繁体   English

wsdl Java客户端上的“找不到符号”

[英]“cannot find symbol” on a wsdl Java Client

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. 不知道为什么,但是tut没有通过,所以我只是在家中经历了,但是我停留在最后一部分。

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. 我正在尝试编写Java WSDL客户端以访问http://www.nanonull.com/TimeService/TimeService.asmx?WSDL-我应该输入UTC + 10以显示当前时间。 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? 对我在做什么错有任何想法吗?

Did you mean 你的意思是

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

with a lowercase g ? 小写的g Java method names are case-sensitive, so it won't recognize the method if you get its letter casing wrong. Java方法名称区分大小写,因此如果您的字母大小写错误,它将无法识别该方法。 As per both WSDL's TimeServiceSoap documentation and Java naming conventions, method names are in camel case beginning with a lowercase letter. 根据WSDL的TimeServiceSoap文档和Java命名约定,方法名称以驼峰式表示,以小写字母开头。

What does your TimeServiceSoap look like? 您的TimeServiceSoap什么样的?

Perhaps you meant to use getTimeZoneTime() (starting with a lower case letter)? 也许您打算使用getTimeZoneTime() (以小写字母开头)?

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

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