2
I’m trying to create a Web Service in JAVA so it can be consumed by an Android application. I need to use a Cloud technology, and only found the free Openshift and best recommended for now... Well, I already created my project in Eclipse. I already have all the tools. I already sent the project to Openshift, etc. The problem is this: (Note: I am beginner)
I created a connection class with the database:
package conectaMySql;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConectaMySql {
private static final String URL = "link do MySql dado pela OpenShift";
private static final String USER = "login do MySql dado pela OpenShift";
private static final String SENHA = "senha do MySql dada pela OpenShift";
public static Connection obterConexao() throws SQLException{
try{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
return DriverManager.getConnection(URL, USER, SENHA);
}
}
I created another class with the following data:
package classesDao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import classes.*;
import conectaMySql.*;
public class AdministradorDao {
public boolean insertAdmin(Administrador admin){
try {
Connection conn = ConectaMySql.obterConexao();
String queryInserir = "INSERT INTO Administrador VALUES (?, ?)";
PreparedStatement ppStm = conn.prepareStatement(queryInserir);
ppStm.setString(1, admin.getLogin());
ppStm.setString(2, admin.getSenha());
ppStm.executeUpdate();
conn.close();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
}
Disregarding the concept of MVC, rsrsrs... How can I make this class available as a service? I researched a lot on the internet, but I don’t know very well English (I know I’m chipped, and the translation tool helped me a lot), but unfortunately I didn’t find anything concrete. I saw some things about web.xml, etc... But I’m still in the dark! And now, who can help me?
I just want my wsdl :(
– Jedaias Rodrigues
You want to expose your DAO as a SOAP service, that’s it?
– Victor Stafusa
exactly that! I saw that I need to configure some xml, but I did not succeed, rsrs..
– Jedaias Rodrigues
Needs to be SOAP?
– utluiz
Jedaias, why don’t you make a Webservice REST using the JAX-RS API? It’s very simple, it will only depend on what implementation the server has, or you can embark on your project, be it Resteasy or for example Jersey.
– Wakim