indiWiz.com

Subhash's Tech Log

Quick WebService in Java 6

without comments

To write a quick JAX-WS webservice in Java 6:

package test;

import javax.xml.ws.Endpoint;

@javax.jws.WebService
public class MyWebService{

  @javax.jws.WebMethod
  public String getQuote(String name){
    return "1234.56";
  }

  public static void main(String[] arg){
    Endpoint end = Endpoint.create(new MyWebService());
    end.publish("http://localhost:1000/MyWebService");
  }
}

To compile and run:

$ apt -d bin/ MyWebService.java
$ java -cp bin test.MyWebService

Written by Subhash Chandran

November 18th, 2008 at 9:16 am

Posted in Java

Tagged with , ,

Leave a Reply