Testing the web service

Having generated the web service artifacts, packaged and deployed the web service, generated the runtime JAR file for the web service client, and compiled the client class, next we shall test the web service client. We shall run the build.xml targets in the following order:

  • server target: To generate and deploy the web service WAR file to the GlassFish Server
  • client target: To generate the JAR file using the -clientjar option of wsimport and compile the client class
  • run target: To run the client class

Right-click on the server target and select Run Target:

Testing the web service

The output from the server target indicates that the clean, setup, build-server-wsdl, create-war, and deploy targets are run to deploy the clientjar.war file to the GlassFish Server:

clean:
Deleting directory C:UsersdvohraDocumentsNetBeansProjectsHelloWSuild
setup:
Created dir: C:UsersdvohraDocumentsNetBeansProjectsHelloWSuild
Created dir: C:UsersdvohraDocumentsNetBeansProjectsHelloWSuildclasses
Created dir: C:UsersdvohraDocumentsNetBeansProjectsHelloWSuildwar
build-server-wsdl:
parsing WSDL...
Generating code...
Compiling code...
Compiling 1 source file to C:UsersdvohraDocumentsNetBeansProjectsHelloWSuildclasses
create-war:
Building war: C:UsersdvohraDocumentsNetBeansProjectsHelloWSuildwarclientjar.war
deploy:
Copying 1 file to C:glassfish3glassfishdomainsdomain1autodeploy
BUILD SUCCESSFUL (total time: 21 seconds)

The clientjar WAR file is deployed on the Oracle GlassFish Server, as shown in the following screenshot:

Testing the web service

Next, run the client target to generate the runtime JAR file and compile the client class. Right-click on the client target and select Run Target:

Testing the web service

The generate-client and client targets start running and the runtime JAR file HelloWSServiceClient.jar is generated:

generate-client:
Consider using <depends>/<produces> so that wsimport won't do unnecessary compilation
parsing WSDL...
Downloading the WSDL and associated metadata
Generating code...
Compiling code...
Archiving the generated artifacts in to C:UsersdvohraDocumentsNetBeansProjectsHelloWSuildclassesHelloWSServiceClient.jar.
client:
Compiling 1 source file to C:UsersdvohraDocumentsNetBeansProjectsHelloWSuildclasses
BUILD SUCCESSFUL (total time: 9 seconds)

The build classes generated by the build-server-wsdl and client Ant tasks, and the client JAR generated by the generate-client task are shown in the following screenshot:

Testing the web service

Next, test the client class by running the run target. Right-click on the run target and select Run Target:

Testing the web service

The client class runs and the web service gets invoked to generate a Hello message as shown in the following screenshot:

Testing the web service

The output from the run target is as follows:

run:
Hello John Smith. Welcome to Web Services!
BUILD SUCCESSFUL (total time: 10 seconds)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.202.27