ashutiwari4

Untitled

Mar 31st, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. public static final String SOAP_ACTION_DISCOVER_SERVICES = "http://tempuri.org/DiscoverService";
  2. public static final String METHOD_NAME_DISCOVER_SERVICES = "DiscoverService";
  3.  
  4. public AsyncTask<String, Void, String> discoverServices() {
  5. return new AsyncTask<String, Void, String>() {
  6. @Override
  7. protected void onPreExecute() {
  8. super.onPreExecute();
  9. }
  10.  
  11. @Override
  12. protected String doInBackground(String... params) {
  13. String resultData = "null";
  14. try {
  15. SoapObject request = new SoapObject(Splash.NAMESPACE,
  16. METHOD_NAME_DISCOVER_SERVICES);
  17.  
  18. PropertyInfo pi = new PropertyInfo();
  19. pi.setName("user");
  20.  
  21. User user = new User();
  22. user.setName("Alka Shukla");
  23. user.setUserId("[email protected]");
  24. user.setPassword("demeler@123");
  25. user.setEmail("[email protected]");
  26. user.setRole("admin");
  27.  
  28. pi.setValue(user);
  29. pi.setType(User.USER_CLASS);
  30. request.addProperty(pi);
  31.  
  32. SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
  33. SoapEnvelope.VER11);
  34. envelope.dotNet = true;
  35. System.setProperty("http.keepAlive", "true");
  36. envelope.setOutputSoapObject(request);
  37. HttpTransportSE androidHttpTransport = new HttpTransportSE(
  38. Splash.SERVICE_URL, 10000);
  39. androidHttpTransport.call(SOAP_ACTION_DISCOVER_SERVICES, envelope);
  40. SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
  41.  
  42. resultData = result.toString();
  43. Log.e("DiscoverServices", "ResultData: " + resultData);
  44.  
  45.  
  46. //JSONObject ja = new JSONObject(resultData);
  47.  
  48.  
  49. } catch (Exception e) {
  50. e.printStackTrace();
  51. }
  52. return resultData;
  53. }
  54.  
  55.  
  56. @Override
  57. protected void onPostExecute(String result) {
  58. if (result.contains("Err:"))
  59. dialog(TransactionActivity.this, "Info", "Unable to update Meeting.", true);
  60. else {
  61. dialog(TransactionActivity.this, "Info", "Your meeting " + _meetingNameEditText.getText().toString().trim() + " from " + _timeBookingEditText.getText().toString().replace("-", "to")
  62. + " updated successfully.", true);
  63. super.onPostExecute(result);
  64. }
  65. }
  66. };
  67. }
  68. }
  69.  
  70.  
  71.  
  72.  
  73. class User implements KvmSerializable {
  74. public static Class USER_CLASS = new User().getClass();
  75. public String Name, UserId, Password, Email, Role;
  76.  
  77. public String getName() {
  78. return Name;
  79. }
  80.  
  81. public void setName(String name) {
  82. Name = name;
  83. }
  84.  
  85. public String getUserId() {
  86. return UserId;
  87. }
  88.  
  89. public void setUserId(String userId) {
  90. UserId = userId;
  91. }
  92.  
  93. public String getPassword() {
  94. return Password;
  95. }
  96.  
  97. public void setPassword(String password) {
  98. Password = password;
  99. }
  100.  
  101. public String getEmail() {
  102. return Email;
  103. }
  104.  
  105. public void setEmail(String email) {
  106. Email = email;
  107. }
  108.  
  109. public String getRole() {
  110. return Role;
  111. }
  112.  
  113. public void setRole(String role) {
  114. Role = role;
  115. }
  116.  
  117. @Override
  118. public Object getProperty(int i) {
  119.  
  120. switch (i) {
  121. case 0:
  122. return Name;
  123. case 1:
  124. return UserId;
  125. case 2:
  126. return Password;
  127. case 3:
  128. return Email;
  129. case 4:
  130. return Role;
  131. default:
  132. return null;
  133. }
  134. }
  135.  
  136. @Override
  137. public int getPropertyCount() {
  138. return 5;
  139. }
  140.  
  141. @Override
  142. public void setProperty(int i, Object value) {
  143. switch (i) {
  144. case 0:
  145. Name = value.toString();
  146. break;
  147. case 1:
  148. UserId = value.toString();
  149. break;
  150. case 2:
  151. Password = value.toString();
  152. break;
  153. case 3:
  154. Email = value.toString();
  155. break;
  156. case 4:
  157. Role = value.toString();
  158. break;
  159. default:
  160. break;
  161. }
  162.  
  163. }
  164.  
  165. @Override
  166. public void getPropertyInfo(int i, Hashtable hashtable, PropertyInfo info) {
  167. switch (i)
  168. {
  169. case 0:
  170. info.type = PropertyInfo.STRING_CLASS;
  171. info.name = "Name";
  172. break;
  173. case 1:
  174. info.type = PropertyInfo.STRING_CLASS;
  175. info.name = "UserId";
  176. break;
  177. case 2:
  178. info.type = PropertyInfo.STRING_CLASS;
  179. info.name = "Password";
  180. break;
  181. case 3:
  182. info.type = PropertyInfo.STRING_CLASS;
  183. info.name = "Email";
  184. break;
  185. case 4:
  186. info.type = PropertyInfo.STRING_CLASS;
  187. info.name = "Role";
  188. break;
  189. default:
  190. break;
  191. }
  192. }
Advertisement
Add Comment
Please, Sign In to add comment