2

I am developing an application which should serve as a client to a Web Service.

I have generated source files based on the WSDL file using the wsimport utility. It works fine on my development machine with JDK 1.7 (e.g. it compiles and runs fine).

I cannot even compile the application in the test environment though, where I have JDK 1.5. I get a bunch of errors like the following:

Cannot find symbol: class WebMethod

Is suspect the problem is with the lesser version of JDK.

What should I do to fix this, e.g. to update the application to become Java 1.5 compatible?

It must be run a standalone console application.

kolossus
  • 20,559
  • 3
  • 52
  • 104
Dušan Rychnovský
  • 11,699
  • 8
  • 41
  • 65
  • I would assume this has something to do with annotations. But it's weird that your program doesn't work on 1.5 since annotations were introduced in 1.5. Maybe you should compile with `-source 1.5` and see if it helps ? – Andrew Logvinov Oct 21 '12 at 20:16
  • I believe to have read that the WebService -like annotations were not added to JSE JDK until Java version 6. I'm not sure how to fix this though (e.g. which JARs to include) as installing JEE JDK might not be an option. – Dušan Rychnovský Oct 21 '12 at 20:21
  • It turned out that it was viable to upgrade to Java 1.6 in the production environment. I'm not going to change the original question to reflect this fact though, as it would not make sense any more. – Dušan Rychnovský Oct 22 '12 at 10:59

2 Answers2

3

You're correct, it is a function of your JDK, JAX-WS(annotations) was included in the J2SE JDK with v1.6. Doesn't exist in 1.5. It lives outside of the JDK as Project Metro, sample code

Community
  • 1
  • 1
kolossus
  • 20,559
  • 3
  • 52
  • 104
0

You can regenerate the source classes using the wsimport utility with -target 2.0 option.

The generated source is jdk 1.5 compliant and doesn't use the @WebService and @WebMethod annotation (introduced with jdk 1.6).

The client class will be generated with the @WebServiceClient annotation contained in the javax.xml.ws package

@WebServiceClient(name = "ContestService", targetNamespace = "", wsdlLocation = "file:/C:/sviluppo/Lavoro/ContestWS/contestWS.wsdl")
Pavoletto
  • 140
  • 10