Wednesday, October 17, 2012

SOAP Request Bean Designing with implements KvmSerializable


import java.util.Hashtable;

import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;

public class UserLoginBean implements KvmSerializable {

       public static Class UserLoginBean_CLASS = UserLoginBean.class;

       private String UserName;
       private String Password;
       private String Status;

       public UserLoginBean() {
       }

       public UserLoginBean(SoapObject response) {
              this.UserName = response.getProperty("UserName").toString();
              this.Password = response.getProperty("Password").toString();
              this.Status = response.getProperty("Status").toString();
       }

       public String getUserName() {
              return UserName;
       }

       public void setUserName(String userName) {
              UserName = userName;
       }

      
       public String getPassword() {
              return Password;
       }

       public void setPassword(String password) {
              Password = password;
       }

      
       public String getStatus() {
              return Status;
       }

       public void setStatus(String status) {
              Status = status;
       }

       @Override
       public Object getProperty(int index) {
              Object object = null;
              switch (index) {
              case 0:
                     object = this.UserName;
              case 1:
                     object = this.Password;
                     break;
              case 2:
                     object = this.Status;
                     break;
              }
              return object;
       }

       @Override
       public int getPropertyCount() {
              return 3;
       }

       @Override
       public void getPropertyInfo(int index, Hashtable arg1,
                     PropertyInfo propertyInfo) {
              switch (index) {
              case 0:
                     propertyInfo.name = "UserName";
                     propertyInfo.type = PropertyInfo.STRING_CLASS;
                     break;
             
              case 1:
                     propertyInfo.name = "Password";
                     propertyInfo.type = PropertyInfo.STRING_CLASS;
                     break;
             
              case 2:
                     propertyInfo.name = "Status";
                     propertyInfo.type = PropertyInfo.STRING_CLASS;
                     break;
              }

       }

       @Override
       public void setProperty(int index, Object object) {

              switch (index) {
              case 0:
                     this.UserName = object.toString();
                     break;
             
              case 1:
                     this.Password = object.toString();
                     break;
             
              case 2:
                     this.Status = object.toString();
                     break;
              }
       }

}

No comments:

Post a Comment