Advertisement
Guest User

Untitled

a guest
May 5th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  2. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  3. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  6. <SOAP-ENV:Body>
  7. <SOAP-ENV:Fault>
  8. <faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode>
  9. <faultactor xsi:type="xsd:string"></faultactor>
  10. <faultstring xsi:type="xsd:string">Operation &apos;&apos; is not defined in the WSDL for this service
  11. </faultstring>
  12. <detail xsi:type="xsd:string"></detail>
  13. </SOAP-ENV:Fault>
  14.  
  15. <?php
  16. require_once('lib/nusoap.php');
  17.  
  18. $data = json_decode(file_get_contents("php://input"), true);
  19.  
  20. $file_name = $data['file_name'];
  21. $location = $data['location'];
  22.  
  23. $client = new nusoap_client('http://servername:port/WebService/server.php?wsdl', true);
  24.  
  25. if ($SERVER['REQUEST_METHOD'] == 'POST') {
  26. $err = $client->getError();
  27.  
  28. if ($err) {
  29. echo "<h2> Constructor error </h2><pre>" . $err. "</pre>" ;
  30. echo "<h2> Debug </h2><pre>" . htmlspecialchars($client->getdebug(), ENT_QUOTES) . "</pre>" ;
  31. exit();
  32. }
  33.  
  34. $datas = array (
  35. 'file_name' => $file_name,
  36. 'location' => $location
  37. );
  38.  
  39. $result = $client->call('InsertData', $datas);
  40.  
  41. if ($client->fault) {
  42. echo "<h2> Fault (Expect - The request contains an invalid SOAP Body)</h2> <pre>" ;
  43. print_r ($result);
  44. echo "</pre>";
  45. } else {
  46. $err = $client->getError ();
  47. if ($err) {
  48. echo "<h2> Error </h2><pre>" . $err. "</pre>";
  49. } else {
  50. print_r ($result);
  51. }
  52. }
  53. } else if ($_SERVER['REQUEST_METHOD'] != 'POST') {
  54. echo "Method is not POST " ;
  55. }
  56.  
  57. ?>
  58.  
  59. <?php
  60. require_once('lib.nusoap');
  61.  
  62. $server = new soap_server();
  63. $server->configureWSDL('Database Sample Insertion', 'urn:Insert');
  64. $server->soap_defenconding = 'UTF-8' ;
  65.  
  66. $server->register('InsertData',
  67. array (
  68. 'file_name' => 'xsd:file_name',
  69. 'location' => 'xsd:location'
  70. ),
  71. array ('return' => 'xsd:string'),
  72. 'urn:Insert',
  73. 'urn:Insertwsdl#InsertDate',
  74. 'rpc',
  75. 'literal'
  76. );
  77.  
  78. function InsertData ($file_name, $location) {
  79. $db_host = 'localhost';
  80. $db_username = 'username';
  81. $db_password = '' ;
  82. $db_name = 'sample' ;
  83.  
  84. $conn = new mysqli ($db_host, $db_username, $db_password, $db_name);
  85.  
  86. if ($conn->connect_error) {
  87. trigger_error('Database connection failed : ' .$conn->connect_error , E_USER_ERROR);
  88. }
  89.  
  90. $sql = "INSERT INTO transaction (`filename`, `location`) VALUES ('$file_name', '$location')";
  91.  
  92. $query = $conn->query($sql);
  93.  
  94. }
  95.  
  96. $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '' ;
  97. $server->service($HTTP_RAW_POST_DATA);
  98.  
  99.  
  100. ?>
  101.  
  102. if (function_exists('getallheaders')){ ...
  103.  
  104. if (0 && function_exists('getallheaders')){ ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement