Android Open Source - ArrecebaAndroid Web Service






From Project

Back to project page ArrecebaAndroid.

License

The source code is released under:

GNU General Public License

If you think the Android project ArrecebaAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package br.com.projetointegrador.DAO;
/*from  ww w.  j  a v a2  s.  c o m*/
import java.util.Enumeration;
import java.util.Hashtable;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.DataSoapSerializationEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;

public class WebService {
  public static final String URL = "http://192.168.43.5/ArrecebaManager";
  protected static final String NAMESPACE = "http://tempuri.org/";
  protected static final String APPTOKEN = "49849FF2-DC74-45EF-ABE4-A0A0FB3A08BD";
  
  public static Object InvokeMethod(String URL , String MethodName) {
    return InvokeMethod(URL , MethodName , null);
  }
  
  public static Object InvokeMethod(String URL , String MethodName , Hashtable<String , Object> parameters) {
    SoapObject request = GetSoapObject(MethodName , parameters);
    SoapSerializationEnvelope envelope = GetEnvelope(request);
    return MakeCall(URL , envelope , NAMESPACE , MethodName);
  }
  
  public static SoapObject GetSoapObject(String MethodName , Hashtable<String , Object> parameters) {
    SoapObject so = new SoapObject(NAMESPACE , MethodName);
    
    if (parameters != null) {
      Enumeration<String> Estring = parameters.keys();
      
      while (Estring.hasMoreElements()) {
        String key = (String) Estring.nextElement();
        
        so.addProperty(key , parameters.get(key));
      }
    }
    
    return so;
  }
  
  public static DataSoapSerializationEnvelope GetEnvelope(SoapObject Soap) {
    DataSoapSerializationEnvelope envelope = new DataSoapSerializationEnvelope(DataSoapSerializationEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(Soap);
    return envelope;
  }
  
  /**
   * @param URL - The complete URL where the web service resides
   * @param Envelope - The envelope to be passed
   * @param NAMESPACE - The web method namespace
   * @param METHOD_NAME - The method name
   * @return - SoapObject containing the resultset
   */
  public static Object
    MakeCall(String URL , SoapSerializationEnvelope Envelope , String NAMESPACE , String METHOD_NAME) {
    AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
    Object obj = null;
    try {
      androidHttpTransport.call(NAMESPACE + METHOD_NAME , Envelope);
      obj = Envelope.getResponse();
    } catch (Exception e) {
      e.printStackTrace();
      
    }
    return obj;
  }
  
  protected static boolean hasError(Object response) {
    if (response instanceof SoapFault) {
      return true;
    }
    return false;
  }
  
}




Java Source Code List

br.com.projetointegrador.ArrecebaAndroidActivity.java
br.com.projetointegrador.SplashActivity.java
br.com.projetointegrador.DAO.CrudDAO.java
br.com.projetointegrador.DAO.InteresseDAO.java
br.com.projetointegrador.DAO.ProdutoDAO.java
br.com.projetointegrador.DAO.SQLite.java
br.com.projetointegrador.DAO.SystemDAO.java
br.com.projetointegrador.DAO.UserDAO.java
br.com.projetointegrador.DAO.WebService.java
br.com.projetointegrador.Frm.FrmCrudList.java
br.com.projetointegrador.Frm.FrmInteresse.java
br.com.projetointegrador.Frm.FrmLogadoBase.java
br.com.projetointegrador.Frm.FrmLogin.java
br.com.projetointegrador.Frm.FrmProdutos.java
br.com.projetointegrador.Frm.FrmRegistrarse.java
br.com.projetointegrador.TO.Categoria.java
br.com.projetointegrador.TO.Crud.java
br.com.projetointegrador.TO.Interesse.java
br.com.projetointegrador.TO.Produto.java
br.com.projetointegrador.TO.User.java
br.com.projetointegrador.View.InteresseViewHolder.java
br.com.projetointegrador.View.ProdutoViewHolder.java
br.com.projetointegrador.table.TbUser.java