Advertisement
Guest User

Untitled

a guest
Feb 24th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <?php
  2.  
  3. $wsdl = "https://<your_web_service_url>?wsdl";
  4. $client = new SoapClient($wsdl, array('trace'=>1)); // The trace param will show you errors stack
  5.  
  6. // web service input params
  7. $request_param = array(
  8. "param1" => $value1,
  9. "param2" => $value2,
  10. "param3" => $value3,
  11. "param4" => $value4
  12. );
  13.  
  14. try
  15. {
  16. $responce_param = $client->webservice_methode_name($request_param);
  17. //$responce_param = $client->call("webservice_methode_name", $request_param); // Alternative way to call soap method
  18. }
  19. catch (Exception $e)
  20. {
  21. echo "<h2>Exception Error!</h2>";
  22. echo $e->getMessage();
  23. }
  24.  
  25. <?php
  26. require_once('lib/nusoap.php');
  27.  
  28. $wsdl = "http://<your_web_service_url>?wsdl";
  29. $client = new nusoap_client($wsdl, 'wsdl');
  30.  
  31. // Input params
  32. $username = "username";
  33. $password = "pass";
  34.  
  35. // In this demo, we use json data , you can use any other data format for same
  36. $json = '{"param1":"value1","param2":"value2"}';
  37.  
  38. $client->setCredentials($username, $password);
  39. $error = $client->getError();
  40.  
  41. if ($error)
  42. {
  43. echo $error; die();
  44. }
  45.  
  46. $action = "webservice_methode_name"; // webservice method name
  47.  
  48. $result = array();
  49.  
  50. if (isset($action))
  51. {
  52. $result['response'] = $client->call($action, $json);
  53. }
  54.  
  55. echo "<h3>Output : </h3>";
  56. echo $result['response'];
  57. echo "<h2>Request</h2>";
  58. echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
  59. echo "<h2>Response</h2>";
  60. echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement