PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/workflow/engine/methods/services/demoSoap.php

https://bitbucket.org/ferOnti/processmaker
PHP | 273 lines | 238 code | 31 blank | 4 comment | 8 complexity | 15dbcdd5d86c58402b8aaaff37a840a8 MD5 | raw file
  1. <html>
  2. <head>
  3. <title>SugarCRM test webservices</title>
  4. </head>
  5. <style type="text/css">
  6. ul.krumo-node {
  7. margin: 0px;
  8. padding: 0px;
  9. background-color: white;
  10. }
  11. ul.krumo-node ul {
  12. margin-left: 20px;
  13. }
  14. * html ul.krumo-node ul {
  15. margin-left: 24px;
  16. }
  17. div.krumo-root {
  18. border: solid 1px black;
  19. margin: 1em 0em;
  20. text-align: left;
  21. }
  22. ul.krumo-first {
  23. font: normal 11px tahoma, verdana;
  24. border: solid 1px white;
  25. }
  26. li.krumo-child {
  27. display: block;
  28. list-style: none;
  29. padding: 0px;
  30. margin: 0px;
  31. overflow: hidden;
  32. }
  33. div.krumo-element {
  34. cursor: default;
  35. display: block;
  36. clear: both;
  37. white-space: nowrap;
  38. background-color: white;
  39. background-image: url(/Krumo/skins/schablon.com/empty.gif);
  40. background-repeat: no-repeat;
  41. background-position: 6px 5px;
  42. padding: 2px 0px 3px 20px;
  43. }
  44. * html div.krumo-element {
  45. padding-bottom: 3px;
  46. line-height: 13px;
  47. }
  48. a.krumo-name {
  49. color: navy;
  50. font: bold 13px courier new;
  51. line-height: 12px;
  52. }
  53. </style>
  54. <?php
  55. if (isset( $_POST["epr"] )) {
  56. $_SESSION['END_POINT'] = $_POST["epr"];
  57. }
  58. $endpoint = isset( $_SESSION['END_POINT'] ) ? $_SESSION['END_POINT'] : 'http://sugar.opensource.colosa.net/soap.php';
  59. $sessionId = isset( $_SESSION['SESSION_ID'] ) ? $_SESSION['SESSION_ID'] : '';
  60. ?>
  61. <form method="post" action="">
  62. <div class="krumo-root">
  63. <ul class="krumo-node krumo-first">
  64. <div class="krumo-element">
  65. End Point <input type="text" size="80" maxlength="160" name="epr"
  66. value="<?php echo $endpoint ?>"> <input type="submit"
  67. value="change endpoint" name="action">
  68. </div>
  69. </ul>
  70. </div>
  71. </form>
  72. <form method="post" action="">
  73. <div class="krumo-root">
  74. <a class="krumo-name">login</a>
  75. <ul class="krumo-node krumo-first">
  76. <div>
  77. User Id <input type="text" size="16" maxlength="20" name="user"
  78. value="admin"> Password <input type="text" size="16" maxlength="20"
  79. name="pass" value="sample"> <input type="submit" value="login"
  80. name="action">
  81. </div>
  82. </ul>
  83. </div>
  84. </form>
  85. <form method="post" action="">
  86. <div class="krumo-root">
  87. <a class="krumo-name">createUser</a>
  88. <ul class="krumo-node krumo-first">
  89. <div class="krumo-element">
  90. Session Id <input type="text" size="36" maxlength="32"
  91. name="sessionid" value="<?php print $sessionId ?>">
  92. </div>
  93. <div class="krumo-element">
  94. User Id <input type="text" size="16" maxlength="20" name="userid"
  95. value=""> <img src="/Krumo/skins/schablon.com/empty.gif"> First
  96. Name <input type="text" size="16" maxlength="20" name="firstname"
  97. value=""> <img src="/Krumo/skins/schablon.com/empty.gif"> Last Name
  98. <input type="text" size="16" maxlength="20" name="lastname" value="">
  99. <img src="/Krumo/skins/schablon.com/empty.gif"> Email <input
  100. type="text" size="16" maxlength="20" name="email" value=""> <img
  101. src="/Krumo/skins/schablon.com/empty.gif"> Role <input type="text"
  102. size="16" maxlength="20" name="role" value=""> <img
  103. src="/Krumo/skins/schablon.com/empty.gif"> <input type="submit"
  104. value="createUser" name="action">
  105. </div>
  106. </ul>
  107. </div>
  108. </form>
  109. <form method="post" action="">
  110. <div class="krumo-root">
  111. <a class="krumo-name">assignUserToGroup</a>
  112. <ul class="krumo-node krumo-first">
  113. <div class="krumo-element">
  114. Session Id <input type="text" size="36" maxlength="32"
  115. name="sessionid" value="<?php print $sessionId ?>">
  116. </div>
  117. <div class="krumo-element">
  118. User Id <input type="text" size="16" maxlength="20" name="userid"
  119. value=""> <img src="/Krumo/skins/schablon.com/empty.gif"> Group Id
  120. <input type="text" size="16" maxlength="20" name="groupid" value="">
  121. <input type="submit" value="assignUserToGroup" name="action">
  122. </div>
  123. </ul>
  124. </div>
  125. </form>
  126. <form method="post" action="">
  127. <div class="krumo-root">
  128. <a class="krumo-name">newCase</a>
  129. <ul class="krumo-node krumo-first">
  130. <div class="krumo-element">
  131. Session Id <input type="text" size="36" maxlength="32"
  132. name="sessionid" value="<?php print $sessionId ?>">
  133. </div>
  134. <div class="krumo-element">
  135. Process Id <input type="text" size="16" maxlength="20"
  136. name="processid" value=""> <img
  137. src="/Krumo/skins/schablon.com/empty.gif"> Variables <input
  138. type="text" size="16" maxlength="20" name="variables" value=""> <input
  139. type="submit" value="newCase" name="action">
  140. </div>
  141. </ul>
  142. </div>
  143. </form>
  144. <?php
  145. if (! isset( $_POST["action"] ) or $_POST["action"] == 'change endpoint') {
  146. die();
  147. }
  148. $action = $_POST["action"];
  149. //krumo ($_POST);
  150. ini_set( "soap.wsdl_cache_enabled", "0" ); // disabling WSDL cache
  151. switch ($action) {
  152. case 'login':
  153. $user = $_POST["user"];
  154. $pass = md5( $_POST["pass"] );
  155. $wsdl = $endpoint;
  156. //$client = new SoapClient( $endpoint );
  157. $client = new SoapClient( null, array ('location' => $endpoint,'uri' => 'http://www.sugarcrm.com/sugarcrm','soap_version' => SOAP_1_1, //SOAP_1_2 - 1.2 not supported by sugar nusoap
  158. 'trace' => 1,'exceptions' => 0,'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5
  159. ) );
  160. $params = array ('user_name' => $user,'password' => $pass,'version' => '1'
  161. );
  162. $result = $client->__SoapCall( 'login', array ('user_auth' => $params,'application_name' => 'ProcessMaker'
  163. ) );
  164. if ($result->error->number == 0) {
  165. $_SESSION['SESSION_ID'] = $result->id;
  166. $session = $result->id;
  167. $res = $client->__getFunctions();
  168. krumo( $res );
  169. $params = array ('session' => $result->id
  170. );
  171. $res = $client->__SoapCall( 'is_user_admin', array ($session
  172. ) );
  173. if ($res == 1)
  174. print "is Administrator user";
  175. $first_name = 'juan';
  176. $last_name = 'perez';
  177. $phone = '7235131';
  178. $fax = '2454545';
  179. $companyname = 'ABC company';
  180. $prod_desc = 'descripcion del prod 1 ';
  181. $user_guid = '';
  182. $set_entry_params = array ('session' => $session,'module_name' => 'Leads',
  183. 'name_value_list' => array (array ('name' => 'last_name','value' => $last_name
  184. ),array ('name' => 'status','value' => 'New'
  185. ),array ('name' => 'phone_work','value' => $phone
  186. ),array ('name' => 'phone_fax','value' => $fax
  187. ),array ('name' => 'account_name','value' => $companyname
  188. ),array ('name' => 'lead_source','value' => 'Web Site'
  189. ),array ('name' => 'description','value' => $prod_desc
  190. ),array ('name' => 'email1','value' => 'juan@colosa.com'
  191. ),array ('name' => 'assigned_user_id','value' => $user_guid
  192. )
  193. )
  194. );
  195. $res = $client->__SoapCall( 'set_entry', $set_entry_params );
  196. krumo( $res );
  197. //$query = "contacts.email1 != '' ";
  198. //$orderby = 'email1 desc ';
  199. $query = '';
  200. $orderby = '';
  201. $fields = array ('id','first_name','last_name','account_name','account_id','email1','phone_work'
  202. );
  203. $params = array ($session,'Leads',$query,$orderby,0,$fields,100,false
  204. );
  205. $res = $client->__SoapCall( 'get_entry_list', $params );
  206. krumo( $res );
  207. }
  208. break;
  209. case 'processList':
  210. $wsdl = PATH_METHODS . "services" . PATH_SEP . "pmos.wsdl";
  211. $endpoint = $wsdl;
  212. $client = new SoapClient( $endpoint );
  213. $params = array ('sessionId' => $sessionId
  214. );
  215. $result = $client->__SoapCall( 'processesList', array ($params
  216. ) );
  217. krumo( $result );
  218. die();
  219. break;
  220. default:
  221. krumo( $_POST );
  222. die();
  223. }
  224. ?>
  225. <div class="krumo-root">
  226. <ul class="krumo-node krumo-first">
  227. <li class="krumo-child">
  228. <div class="krumo-element">
  229. status_code (<em class="krumo-type">Integer</em>) <strong
  230. class="krumo-integer"><?php echo $result->error->number ?></strong>
  231. </div>
  232. <div class="krumo-element">
  233. message (<em class="krumo-type">string</em>) <strong
  234. class="krumo-integer"><?php echo $result->error->name ?></strong>
  235. </div>
  236. <div class="krumo-element">
  237. timestamp (<em class="krumo-type">string</em>) <strong
  238. class="krumo-integer"><?php echo $result->error->description ?></strong>
  239. </div>
  240. </li>
  241. </ul>
  242. </div>