Web Services inside a Console app in NetBeans

View: New views
1 Messages — Rating Filter:   Alert me  

Web Services inside a Console app in NetBeans

by Cristiano Costantini :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all and thanks for your precious work in developing NetBeans.

I'm writing to let you know of a feature I would like to see inside the
IDE, I actually don't know if it is hard to achieve or it's easy...
I would like to be able to add and edit a Web Service inside a simple
"Java Application Project" or inside a "Java Library Project".

I'm using NetBeans 6.5 beta, and I actually do obtain the same result by
manually adding Jax-WS and JaxB jars, add a simple Java class, and
manually annotating it with @WebService etc.
I do run the web Service inside Main of a console app by using
javax.xml.ws.Endpoint. However I do not get Web Service editing support
as I do get when I build a "Web Application Project"... (I can only add a
Web Service Client)

Thank you for the attention,
please don't flame me if I've missed some kind of configuration which
would allow me to obtain what I'm searching for!  :-)

best regards,

Cristiano Costantini,
Italy

PS. Here are two class of a sample self-hosting Web Service using this
approach.

-----------------------------------------------------
package test;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

/**
 *
 * @author ccostantini
 */

@WebService(name = "SayHelloService")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public class Service {
   
    @WebMethod(operationName = "sayHello", action = "urn:#sayHello")
    @WebResult(name = "helloMessage",  partName = "output")
    public String sayHello(
        @WebParam(name = "sayHello",  partName = "input")
        String input)
    {
        return "hello " + input;
    }
}
------------------------------
package test;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.ws.Endpoint;

/**
 *
 * @author ccostantini
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            Endpoint ep = Endpoint.create(new Service());

            URL epURL = new URL("http://localhost:8090/HelloService");
            ep.publish(epURL.toString());
            System.out.println("Endpoint published at " + epURL.toString());

        } catch (MalformedURLException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE,
null, ex);
        }
    }
}