Top Linux Links You Must Click On


JDJ Feature — Java API for XML Web Services (JAX-WS)
Creating a JAX-WS 2.0 Web Service in WebLogic Server 10

Add a target build-client to the build.xml file to generate the client artifacts. Add a clientgen element to the target element. Specify type as JAXWS, destDir as output/clientclass, packageName as webservices.jaxws.client, and wsdl as http://localhost:7001/HelloWsImpl/HelloWsImplService?WSDL.

<clientgen type="JAXWS"
wsdl="http://localhost:7001/HelloWsImpl/HelloWsImplService?WSDL"
destDir="output/clientclass" packageName="webservices.jaxws.client"/>

Add javac elements to the target element to com-pile the client artifact Java classes and the Main.java client Java application. The build.xml file is listed below.

<project name="webservices-simple_client" default="all">
<taskdef name="clientgen"
classname="weblogic.wsee.tools.anttasks.ClientGenTask" />
<target name="build-client"> <clientgen type="JAXWS"
wsdl="http://localhost:7001/HelloWsImpl/HelloWsImplService?WSDL"
destDir="output/clientclass" packageName="webservices.jaxws.client"/>
<javac srcdir="output/clientclass" destdir="output/clientclass" includes="**/*.java"/>
<javac srcdir="src" destdir="output/clientclass"
includes="webservices/jaxws/client/*.java"/></target>
</project>

Run the build-client target to generate the client artifacts and compile the Java classes.

C:\BEA\user_projects\webservices\simple_client> ant build-client

The client artifacts get generated and the Java classes get compiled. The output from the build-client target is shown in Figure 3.

Next, add a target to the build.xml file to run the client Java application Main.java. Add a target run. Also add a path element to specify the classpath to run the Main.java application. The classpath should include the output/clientclass directory that contains the client artifacts and the system property java.class.path. The modified build.xml file is shown below.

<project name="webservices-simple_client" default="all"> <taskdef name="clientgen"
classname="weblogic.wsee.tools.anttasks.ClientGenTask" />
<target name="build-client"> <clientgen type="JAXWS"
wsdl="http://localhost:7001/HelloWsImpl/HelloWsImplService?WSDL"
destDir="output/clientclass" packageName="webservices.jaxws.client"/> <javac
srcdir="output/clientclass" destdir="output/clientclass" includes="**/*.java"/> <javac
srcdir="src" destdir="output/clientclass"
includes="webservices/jaxws/client/*.java"/></target>
<path id="client.class.path">
<pathelement path="output/clientclass"/> <pathelement
path="${java.class.path}"/> </path> <target name="run" >
<java fork="true"
classname="webservices.jaxws.client.Main"failonerror="true" >
<classpath refid="client.class.path"/> </java> </target>
</project>

Next, run the target run.

The Web Service operation hello() gets invoked with a String argument and the result returned by the Web Service gets output as shown in Figure 4.

Conclusion
WebLogic Server 10 Technical Preview supports JEE 5 and the JAX-WS 2.0 Web Services. WebLogic server 10 also provides Ant tasks jwsc and clientgen to generate the Web Service artifacts and client artifacts.

About Deepak Vohra
Deepak Vohra is a Sun Certified Java 1.4 Programmer and a Web developer.

About Ajay Vohra
Ajay Vohra is a senior solutions architect with DataSynapse Inc.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

The example give in this article is too simple. Information given in this article can even be found in weblogic documentation.. so what additional value does this article? to me NIL.

I would have appreciated a more realistic example where webservice is used along with other libraries like beehive controls and then see how you can jwsc to package this application into an .ear or .war. There are a bunch of cases in which jwsc gives warnings and errors and none of them seem to be discussed/explained in this article.


  Subscribe to our RSS feeds now and receive the next article instantly!
In It? Reprint It! Contact advertising(at)sys-con.com to order your reprints!
ADS BY GOOGLE
Subscribe to the World's Most Powerful Newsletters