Weblog

All | Personal | Sun
« Previous month (Feb 2006) | Main | Next month (Apr 2006) »
20060426 Wednesday April 26, 2006

Developing Web services for Mustang in Netbeans I read a very good blog about developing web services in Mustang a few weeks ago. However, described web service is very simple, you didn't need to generate WS artifacts for it. In real cases you might use Exceptions in you web method and then you should run wsgen before publishing web service. I would like to use how to develop this web service in last NetBeans 5.5 builds. For instance, my web service method throws some application exception like this:

     @WebMethod(name="getCountEmails")
     public int getTotalCount(@WebParam(name="email")String eMail) throws MailReportException {
            return reportServ.getMailBySender(eMail).size();
    }
  
Of course, project's target JVM should be jdk 1.6.0. Then, add JAX-WS 2.0 library on project's classpath and add these lines in project's build.xml script:
  <target name="-post-compile" depends="init">
        <echo message="Generate WS artifacts"/>
        <taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen">
            <classpath path="${javac.classpath}"/>
        </taskdef>
        <wsgen
            debug="true"
            keep="true"
            destdir="build/classes"
            resourcedestdir="build/classes"
            sei="your.package.WSImplementation">
            <classpath>
                <pathelement path="${javac.classpath}"/>
                <pathelement location="${java.home}/../lib/tools.jar"/>
                <pathelement location="build/classes"/>
            </classpath>
        </wsgen>
    </target>
This task invokes wsgen and generate requested beans for exception. Now, you can publish web service:
  Endpoint.publish("http://localhost:8080/MyWebService", new MailReportWS());
run your project and test WSDL in browser. Posted by pblaha ( Apr 26 2006, 03:09:58 PM CEST ) Permalink

Calendar

RSS Feeds

Search

Links

Navigation

Referers

Older blog entries