Dúvida: como criar um Web Service em Java?

6 respostas
Marcio_Nogueira

Olá, estou com uma dúvida meio besta, mas vamos lá: como faço para criar um web service em java? Alguém poderia dar um exemplo bem básico?

Um abraço, muito obrigado. :wink:

6 Respostas

B

http://guj.com.br/article.show.logic?id=159

http://faq.javaranch.com/java/WebServicesFaq (mais recomendado, utiliza Axis2)

furutani

Com o eclipse ganimedi é fácil, é só criar uma classe java clicar com o direito e selecionar WebServices em seguida Create WebServices. Dai é só seguir o wizard.

leorbarbosa

bKn:
http://guj.com.br/article.show.logic?id=159

http://faq.javaranch.com/java/WebServicesFaq (mais recomendado, utiliza Axis2)

Segui os passos do primeiro link, e está ocorrendo o erro

HTTP Status 404 - /axis
type Status report
message /axis
description The requested resource (/axis) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.26

Faltou ‘startar’ alguma coisa?

peczenyj

Jersey 8)

666_olodum

Depende do que quer fazer, em web services há dois tipos de implementação SOAP ou REST, abaixo posto um exemplo de codigo do jersey.

<a class="mention" href="/u/path">@Path</a>(“Ws”)

@Produces(“application/xml”)

@Provider

public class Ws {

<a class="mention" href="/u/get">@GET</a>

<a class="mention" href="/u/path">@Path</a>(“caminho”)

public List buscarObjetosPorParametros(

@QueryParam(“obj”) @DefaultValue("") String obj,

@QueryParam(“obj”) @DefaultValue("") String obj,

@QueryParam(“obj”) @DefaultValue("") String obj,

@QueryParam(“obj”) @DefaultValue("") String obj,

@QueryParam(“obj”) @DefaultValue("") String obj)

throws Exception {

List objetos= null;

try {

} catch (Exception ex) {

throw new WebApplicationException(ex,

Response.Status.INTERNAL_SERVER_ERROR);

}

return objetos;

}

}

ASS: A VOZ DO INFERNO.

666_olodum

Depende do que quer fazer, em web services há dois tipos de implementação SOAP ou REST, abaixo posto um exemplo de codigo do jersey.

<a class="mention" href="/u/path">@Path</a>(“Ws”)

@Produces(“application/xml”)

@Provider

public class Ws {

<a class="mention" href="/u/get">@GET</a>

<a class="mention" href="/u/path">@Path</a>(“caminho”)

public List buscarObjetosPorParametros(

@QueryParam(“obj”) @DefaultValue("") String obj,

@QueryParam(“obj”) @DefaultValue("") String obj,

@QueryParam(“obj”) @DefaultValue("") String obj,

@QueryParam(“obj”) @DefaultValue("") String obj,

@QueryParam(“obj”) @DefaultValue("") String obj)

throws Exception {

List objetos= null;

try {

} catch (Exception ex) {

throw new WebApplicationException(ex,

Response.Status.INTERNAL_SERVER_ERROR);

}

return objetos;

}

}

ASS: A VOZ DO INFERNO.

Criado 28 de julho de 2009
Ultima resposta 17 de nov. de 2010
Respostas 6
Participantes 6