Wednesday November 30, 2005 Web service client in EJB module in NetBeans 5.0 I'm working on one J2EE application that has web service client in EJB module. However, NetBeans 5.0 doesn't support web service client for EJB. Since NetBeans uses Ant as build tool is very easy to add this missing feature in NetBeans. We should changes build.properties and add new target in build.xml file. Let's to add support for web service client in NetBeans. These steps create Static generated web service client (JSR-101) in your EJB module:
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
<wsdl location="http://localhost:8080/credit/CreditCardService?WSDL"
packageName="creditsystem.client"/>
</configuration>
Where location attribute represents location of the WSDL file and package is package where stubs will be generated.
wscompile.classpath=${wscompile.tools.classpath}:${j2ee.platform.wscompile.classpath}
wscompile.client.CreditCardService.features=strict,wsi
wscompile.client.CreditCardService.package=creditsystem.client
wscompile.tools.classpath=${java.home}\\..\\lib\\tools.jar
First line setups classpath for wscompile, second one is wscompile options.
<target name="-pre-compile">
<taskdef name="wscompile"
classname="com.sun.xml.rpc.tools.ant.Wscompile"
classpath="${wscompile.classpath}"/>
<copy file="src/conf/CreditCardService-config.xml"
tofile="${build.classes.dir}/META-INF/wsdl/CreditCardService-config.xml"/>
<wscompile gen="true" base="${build.classes.dir}" keep="true" debug="true"
config="${build.classes.dir}/META-INF/wsdl/CreditCardService-config.xml"
classpath="${wscompile.classpath}"/>
<wscompile gen="true" base="${build.dir}/ear-module" keep="true" debug="true"
config="${build.classes.dir}/META-INF/wsdl/CreditCardService-config.xml"
classpath="${wscompile.classpath}"/>
</target>
Here is one issue. You can see that similar task is invoked twice. The hack solves issue that EJB module can
be included in J2EE application or can be standalone. When you build J2EE application with this EJB module then classes are built in different directory then for standalone module. I don't know how to resolve this issue in build.xml. Therefore, I call these two tasks.