I can compile the Java Web Service client fine with the following command:
javac
-classpath lib\spring-ws-2.0.0-M2-all.jar;lib\xml-apis.jar;lib\j2ee.jar;lib\saaj.jar;lib\saaj-impl.jar
WebServiceClient.java
When I actually run it (java WebServiceClient), it gives me the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/ws/client/core/WebServiceTemplate
at WebServiceClient.<init>(WebServiceClient.java:14)
at WebServiceClient.main(WebServiceClient.java:37)
Caused by: java.lang.ClassNotFoundException: org.springframework.ws.client.core.
WebServiceTemplate
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 2 more
Here's the code for WebServiceClient.java:
import java.io.StringReader;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.transport.WebServiceMessageSender;
public class WebServiceClient {
private static final String MESSAGE =
"<message xmlns=\"http://tempuri.org\">Hello Web Service World</message>";
private final WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
public void setDefaultUri(String defaultUri) {
webServiceTemplate.setDefaultUri(defaultUri);
}
// send to the configured default URI
public void simpleSendAndReceive() {
StreamSource source = new StreamSource(new StringReader(MESSAGE));
StreamResult result = new StreamResult(System.out);
webServiceTemplate.sendSourceAndReceiveToResult(source, result);
}
// send to an explicit URI
public void customSendAndReceive() {
StreamSource source = new StreamSource(new StringReader(MESSAGE));
StreamResult result = new StreamResult(System.out);
webServiceTemplate.sendSourceAndReceiveToResult("http://wsdl",
source, result);
}
public static void main(String[] args) throws Exception {
WebServiceClient ws = new WebServiceClient();
ws.setDefaultUri("http://wsdl");
ws.simpleSendAndReceive();
}
}
Any help is appreciated.