Guest User

My consume.php script using the SLIM_Service.php script.

a guest
Apr 5th, 2011
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. <?php
  2. // Load the classes constructed by wsdl2php
  3. require_once './SLIM_Service.php';
  4.  
  5. // Define the SOAP options.
  6. $a_SoapOptions = array
  7. (
  8. 'encoding' => 'UTF-8',
  9. 'exception' => True, // Turn SOAPFaults into Exceptions so PHP can report upon them.
  10. 'trace' => True, // Turn on tracing so we can see EXACTLY what the headers and request/response are.
  11. );
  12.  
  13. // As we are going to need to display XML, use Tidy to make it pretty.
  14. $a_TidyConfig = array
  15. (
  16. 'indent' => 4,
  17. 'indent-attributes' => true,
  18. 'input-xml' => true,
  19. 'output-xml' => true,
  20. 'wrap' => 0,
  21. );
  22. $o_Tidy = new Tidy;
  23.  
  24. $s_WsdlUrl = "http://betaservices.membersolutions.com/Business.PartnerService/svc/SLIM.svc?wsdl";
  25.  
  26. try
  27. {
  28. // Create the service.
  29. $o_Service = new SLIM_Service($s_WsdlUrl, $a_SoapOptions);
  30.  
  31. // Construct the parameter for the HelloWorld method.
  32. $o_HelloWorld = new HelloWorld;
  33.  
  34. // Call the HelloWorld method.
  35. $o_HelloWorldResponse = $o_Service->HelloWorld($o_HelloWorld);
  36.  
  37. // Display the results.
  38. echo PHP_EOL,
  39. // Show trace.
  40. 'Request Headers', PHP_EOL,
  41. '---------------', PHP_EOL,
  42. $o_Service->__getLastRequestHeaders(), PHP_EOL,
  43.  
  44. 'Request (XML)', PHP_EOL,
  45. '-------------', PHP_EOL,
  46. $o_Tidy->repairString($o_Service->__getLastRequest(), $a_TidyConfig), PHP_EOL, PHP_EOL,
  47.  
  48. 'Response Headers', PHP_EOL,
  49. '----------------', PHP_EOL,
  50. $o_Service->__getLastResponseHeaders(), PHP_EOL,
  51.  
  52. 'Response (XML)', PHP_EOL,
  53. '--------------', PHP_EOL,
  54. $o_Tidy->repairString($o_Service->__getLastResponse(), $a_TidyConfig), PHP_EOL, PHP_EOL, PHP_EOL,
  55.  
  56. 'Response (Interpreted)', PHP_EOL,
  57. '----------------------', PHP_EOL,
  58. print_r($o_HelloWorldResponse->HelloWorldResult, True), PHP_EOL;
  59.  
  60. }
  61. catch(Exception $e)
  62. {
  63. echo PHP_EOL,
  64.  
  65. // Show trace.
  66. 'Request Headers', PHP_EOL,
  67. '---------------', PHP_EOL,
  68. $o_WAPI->__getLastRequestHeaders(), PHP_EOL,
  69.  
  70. 'Request (XML)', PHP_EOL,
  71. '-------------', PHP_EOL,
  72. $o_Tidy->repairString($o_Service->__getLastRequest(), $a_TidyConfig), PHP_EOL, PHP_EOL,
  73.  
  74. 'Response Headers', PHP_EOL,
  75. '----------------', PHP_EOL,
  76. $o_Service->__getLastResponseHeaders(), PHP_EOL,
  77.  
  78. 'Response (XML)', PHP_EOL,
  79. '--------------', PHP_EOL,
  80. $o_Tidy->repairString($o_WAPI->__getLastResponse(), $a_TidyConfig), PHP_EOL, PHP_EOL, PHP_EOL,
  81.  
  82. // Show exception.
  83. 'Exception', PHP_EOL,
  84. '---------', PHP_EOL,
  85. $e->getMessage(), PHP_EOL;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment