title: Generate webservice stub from wsdl in Java
body: <p>I am working on eclipse plugin which will have a wizard. This wizard will be available form example from context menu while mouse right click on Java editor.</p>
  
  <p>The wizard will be responsible for collecting such information as:</p>
  
  <ul><li>location of WSDL file</li><li>Package name</li></ul>
  
  <p>When the wizard finishes, I would like to have stub of a webservice described in WSDL generated into package provided earlier.</p>
  
  <p>THE QUESTION IS: How can I generate webservice stub dymanically and from source code (not from command line) and add it to the current project?</p>
  
  <p>Until now, I came across WSDL2Java (Axis), Apache CXF and wsimport. I try to use Apache CXF and wsimport but I'm always getting ClassNotFoundException even though all jars are included into buildpath. I think I might have used them incorrectly.</p>
  
  <p>Please help me folks! Time for that task is running out :-(</p>
  
  <p><b>Little example:</b></p>
  
  <p>Let's say the code is (Apache CXF):</p>
  
  <pre>String[] args = {"-client", "-d", "D:\\test", "D:\test.wsdl" };
  WSDLToJava w = new WSDLToJava(args);
  ToolContext t = new ToolContext();
  w.run(t);</pre>
  
  <p>The first few lines of exception are:<br><br></p>
  
  <pre>
  java.lang.NoClassDefFoundError: org/apache/cxf/tools/wsdlto/WSDLToJava
      at plugin.wsreplication.ui.wizard.component.AddComponentWizard.performFinish(AddComponentWizard.java:160)
      at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:752)
      at plugin.wsreplication.ui.wizard.component.AddComponentWizardDialog.finishPressed(AddComponentWizardDialog.java:39)
      at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:373)
      at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
      at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
      at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
      at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
      at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
      at org.eclipse.jface.window.Window.open(Window.java:801)
      at plugin.wsreplication.ui.action.AddComponentAction.run(AddComponentAction.java:35)
      at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)</pre>