I am learning how to implement web services in Java. Following the example in O'Reilly's book "Learning Java," I downloaded a WSDL file (see http://bit.ly/13moiTh) for a weather service at cdyne.com and generated a set of classes using the wsimport tool.
The first problem was that when I generated a JAR file and referenced it in the Eclipse project, the classes were not recognized. I had to use wsimport -keep and individually copy all source files into the project to make it build.
Next, to make sure that the service was available, I constructed a simple HTTP POST client based on the code from the book. I could successfully access the getCityWeatherByZIP service with that code, so there was no connectivity or authentication issue.
Finally, I tried to access the getCityWeatherByZIP and getCityForecastByZIP services using the automatically-generated web services client code. Both silently failed, i.e. the isSuccess() methods returned false and all response fields were null:
Weather service = new Weather();
WeatherSoap weatherSoap = service.getWeatherSoap();
WeatherReturn weather = weatherSoap.getCityWeatherByZIP(ZIP);
if (weather.isSuccess()) {
System.out.format("%s, %s : %s : Temperature: %s, Wind: %s\n",
weather.getCity(), weather.getState(), weather.getDescription(),
weather.getTemperature(), weather.getWind());
}
else {
System.out.println("Failed to obtain weather");
}
In stepping through the code, in getCityWeatherByZIP() I discovered the following NoSuchMethodException: com.sun.xml.internal.ws.api.message.Packet.setHeaderList(com.sun.xml.internal.ws.api.message.HeaderList)"
This exception occurs in line that says (in the Debug perspective of Eclipse): "SEIStub.invoke(Object, Method, Object[]) line: not available"
Clearly, the Packet.setHeaderList(HeaderList) method does not exist, which is also corroborated by the documentation of the non-internal class: https://jax-ws.java.net/nonav/jax-ws-20-fcs/arch/com/sun/xml/ws/api/message/Packet.html
I am using the latest JDK 1.7 and Eclipse Version: Kepler Service Release 1, Build id: 20130919-0819.
I do not know how to fix this problem. Any help would be appreciated.