Wednesday, October 17, 2012

Android SOAP Service Caller Class


public class UserLoginService {

      
       private static String METHOD_NAME = "method name";
       private static String URL = "service url";

       public UserLoginBean LoginMe(UserLoginBean bean) {

              final String svalue = "bean";

              SoapObject requestObject = new SoapObject(AppConst.NAMESPACE, METHOD_NAME);

              requestObject.addProperty(svalue, bean);

              final SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                           SoapEnvelope.VER11);
              envelope.dotNet = true;

              envelope.setOutputSoapObject(requestObject);

              envelope.addMapping(AppConst.NAMESPACE,
                           UserLoginBean.UserLoginBean_CLASS.getSimpleName(),
                           UserLoginBean.UserLoginBean_CLASS);

              final Object response = new ServiceCaller().call(AppConst.SOAP_ACTION
                           + METHOD_NAME, envelope, URL);

              if (response != null) {
                     try {
                           if (response != null) {
                                  bean = new UserLoginBean((SoapObject) response);
                           }
                     } catch (Exception e) {
                           e.printStackTrace();
                     }
              }

              return bean;
       }

}

No comments:

Post a Comment