Create your webservice on BEA Weblogic, Part four

One more thing before the service is complete, we need to generete some client classes enabling us to write a unit test. The weblogic task for this is called clientgen and the definition should look something like

<taskdef name="clientgen" classname="weblogic.ant.taskdefs.webservices.clientgen.ClientGenTask" classpathref="classpath" />

You can choose between EAR-based and wsdl-based client classes. In the EAR-based case you use the EAR-file you generated with the servicegen task. Since your client probably won´t have access to your EAR-file but the wsdl-file, the wsdl-based client is probably a safer bet if you want to make sure your webservice is ok. To get example code on how to invoke your webservice you can also have a look at the weblogic admin console. Browse to your deployed application/module and you´ll find the code under 'testing/launch test page'. The testcode provided on that particular page uses the wsdl-file generated by weblogic (typically found under http://localhost:7001/your_services/your_test_service?WSDL). Using this file has about the same effect as using EAR-based client classes. Instead you can use the original wsdl-file. To do this, first make sure you haven´t fiddled with the 'saveWSDL'-attribute of the clientgen task. The default value, 'true', tells the task to include the wsdl-file in the client-jar. In your client code you can the specify this wsdl-file, see snippet below.

URL wsdlUrl = getClass().getClassLoader().getResource("package/structure/to/my/wsdl/myWsdl.wsdl");