1.-Abrir eclipse.
File -> MAVEN Project -> Archetype: maven-archetype-quickstart
GroupId: es.example
ArtifactId: webServiceExample
Click en el botón -> Finish.
2.- Añadir dependencia en pom.xml
Guardar los cambios.com.sun.xml.ws jaxws-rt 2.2.5 compile
3.-Crear clase del Web Service. Ej: MyWebService
package es.example.webserviceExample; import javax.jws.WebMethod; import javax.jws.WebService; @WebService public class MyWebService { @WebMethod public double suma(double a, double b) { return a + b; } @WebMethod public double producto(double a, double b) { return a * b; } @WebMethod public double resta(double a, double b) { return a - b; } }
4.-Crear la clase con el método main()
package es.example.webserviceExample; import javax.xml.ws.Endpoint; /** * Class App * */ public class App { public static void main( String[] args ) { Endpoint.publish("http://localhost:8080/MyFirstWebService", new MiWebService()); } }4.-Ejecutamos la aplicación. Run As -> JAVA Application
5.-Introducimos esta dirección en el navegador: http://localhost:8080/MyFirstWebService?wsdl
No hay comentarios:
Publicar un comentario