Welcome!

Java Authors: Maureen O'Gara, Liz McMillan, Walter H. Pinson, III, Yakov Werde, Tony Bishop

Related Topics: Java, Weblogic

Java: Article

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.

More Stories By Deepak Vohra

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

More Stories By Ajay Vohra

Ajay Vohra is a senior solutions architect with DataSynapse Inc.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
nayanj 10/26/07 02:49:39 PM EDT

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.