Database insertion via Webservice

Asked

Viewed 1,833 times

3

Good night,

I know very little about Webservice. And, through tutorials, I managed to create one. The content was taken from this site: Creating Web-Service

The query is successfully made, but now I need that on the page of Webservice, the user enters some information, and this information is entered in the database Postgres.

How do I do it? Is it possible? I need to use some other technology?

I’m lost :/

  • Post some code from your search webservice (editing the question to do this). This way it is possible to know better how you are getting the parameters of your service, accessing the database and displaying the results. It also makes it easier to serve as a basis for crafting a good response that is compatible with the rest of your project.

  • 2

    The simplest way to create a WS in Java, in my opinion is to use JAX-WS, note that you write Java code, and use Annotations. See these links: http://www.linhadecodigo.com.br/artigo/3654/desenvolvendo-e-usando-web-services-em-java.aspx and http://www.mkyong.com/tutorials/jax-ws-tutorials/

  • You need a page for the user to enter data, with the services of the webservice do not believe it is possible to create a registration page, and if it is not going to be the best way to do, the best thing to do is to create a page using jsf, search a little about jsf. And in the same project you can do it.

2 answers

2

I see that you need to have a solid knowledge of what exactly a Web Service is, what its purposes are.

I noticed that you want to know ways to make the "Web Service page" allows the user to enter information and you come to register the data.

There is no Web Service Page.

There are Web Service Operations.

In case, what you want is add a new operation that allows a customer/consumer(which yes, can be an application that provides an interface for a user to type in) of your service add new information.

I recommend you have a solid understanding of what a Web Service is.

Here are some links to get started:

http://pt.wikipedia.org/wiki/Web_service

http://pt.wikipedia.org/wiki/Service-oriented_architecture

https://docs.oracle.com/javaee/6/tutorial/doc/gijvh.html (the latter from Oracle has excellent explanations)

How much your question effectively - Add this method/operation in the same class that implements Webservice

@Webmethod(operationName = "addirMunicipio") public String buscaMunicipio(@Webparam(name = "municipio") String municipio) { //Other logic accessing methods to insert into the Data Bank }

Deploy your Webservice again and this service will already be available.

For consumption, if you want to write a Java client, use the utility wsimport

http://www.mkyong.com/webservices/jax-ws/jax-ws-wsimport-tool-example/

This is an extensive subject and rich in details, hardly you can learn everything only with my answer, so study more, not just follow tutorials, they are important, but understand the purposes behind.

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.