Advertisement
Guest User

Untitled

a guest
Oct 14th, 2013
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. // $client is PHP's SoapClient class
  2. try {
  3. $response = $client->SomeSoapRequest();
  4. }
  5. catch(SoapFault $e){
  6. // handle issues returned by the web service
  7. }
  8. catch(Exception $e){
  9. // handle PHP issues with the request
  10. }
  11.  
  12. HTTP
  13. ----
  14. Unable to parse URL
  15. Unknown protocol. Only http and https are allowed.
  16. SSL support is not available in this build
  17. Could not connect to host
  18. Failed Sending HTTP SOAP request
  19. Failed to create stream??
  20. Error Fetching http headers
  21. Error Fetching http body: No Content-Length: connection closed or chunked data
  22. Redirection limit reached: aborting
  23. Didn't recieve an xml document
  24. Unknown Content-Encoding
  25. Can't uncompress compressed response
  26. Error build soap request
  27.  
  28.  
  29. VersionMismatch
  30. ---------------
  31. Wrong Version
  32.  
  33.  
  34. Client
  35. ------
  36. A SOAP 1.2 envelope can contain only Header and Body
  37. A SOAP Body element cannot have non Namespace qualified attributes
  38. A SOAP Envelope element cannot have non Namespace qualified attributes
  39. A SOAP Header element cannot have non Namespace qualified attributes
  40. Bad Request
  41. Body must be present in a SOAP envelope
  42. Can't find response data
  43. DTD are not supported by SOAP
  44. encodingStyle cannot be specified on the Body
  45. encodingStyle cannot be specified on the Envelope
  46. encodingStyle cannot be specified on the Header
  47. Error cannot find parameter
  48. Error could not find "location" property
  49. Error finding "uri" property
  50. looks like we got "Body" with several functions call
  51. looks like we got "Body" without function call
  52. looks like we got no XML document
  53. looks like we got XML without "Envelope" element
  54. Missing parameter
  55. mustUnderstand value is not boolean
  56. SoapClient::__doRequest() failed
  57. SoapClient::__doRequest() returned non string value
  58. Unknown Data Encoding Style
  59. Unknown Error
  60. DataEncodingUnknown
  61.  
  62.  
  63. MustUnderstand
  64. --------------
  65. Header not understood
  66.  
  67.  
  68. Server
  69. ------
  70. Couldn't find WSDL
  71. DTD are not supported by SOAP
  72. Unknown SOAP version
  73. WSDL generation is not supported yet
  74.  
  75. <?php
  76.  
  77. ini_set('default_socket_timeout', 10);
  78.  
  79. $client = new SoapClient(null,
  80. array(
  81. 'location' => "http://localhost/soapserver.php",
  82. 'uri' => "http://localhost/soapserver.php",
  83. 'trace' => 1
  84. )
  85. );
  86.  
  87. try {
  88. echo $return = $client->__soapCall("add",array(41, 51));
  89. } catch (SoapFault $e) {
  90. echo "<pre>SoapFault: ".print_r($e, true)."</pre>n";
  91. //echo "<pre>faultcode: '".$e->faultcode."'</pre>";
  92. //echo "<pre>faultstring: '".$e->getMessage()."'</pre>";
  93. }
  94.  
  95. ?>
  96.  
  97. <?php
  98.  
  99. function add($a, $b) {
  100. return $a + $b;
  101. }
  102.  
  103. sleep(20);
  104.  
  105. $soap = new SoapServer(null, array('uri' => 'http://localhost/soapserver.php'));
  106. $soap->addFunction("add");
  107. $soap->handle();
  108.  
  109. ?>
  110.  
  111. $client = new SoapClient($wsdl, array("connection_timeout"=>10));
  112.  
  113. // SET SOCKET TIMEOUT
  114. if(defined('RESPONSE_TIMEOUT') && RESPONSE_TIMEOUT != '') {
  115. ini_set('default_socket_timeout', RESPONSE_TIMEOUT);
  116. }
  117.  
  118. class SoapClientWithTimeout extends SoapClient {
  119. public function __soapCall ($params, ---) {
  120. $time_start = microtime(true);
  121. try {
  122. $result = parent::__soapCall ($params, ---);
  123. }
  124. catch (Exception $e) {
  125. $time_request = (microtime(true)-$time_start);
  126. if(
  127. $e->getMessage() == 'Error Fetching http headers' &&
  128. ini_get('default_socket_timeout') < $time_request
  129. ) {
  130. throw new SoapTimeoutException(
  131. 'Soap request most likly timed out.'.
  132. ' It took '.$time_request.
  133. ' and the limit is '.ini_get('default_socket_timeout')
  134. );
  135. }
  136.  
  137. // E: Not a timeout, let's rethrow the original exception
  138. throw $e;
  139. }
  140.  
  141. // All good, no exception from the service or PHP
  142. return $result;
  143. }
  144. }
  145.  
  146. class SoapTimeoutException extends Exception {}
  147.  
  148. $client = new SoapClientWithTimeout();
  149. try {
  150. $response = $client->SomeSoapRequest();
  151. var_dump($response);
  152. }
  153. catch(SoapTimeoutException $e){
  154. echo 'We experienced a timeout! '. $e->getMessage();
  155. }
  156. catch(Exception $e) {
  157. echo 'Exception: '.$e->getMessage();
  158. }
  159.  
  160. ini_set('default_socket_timeout', 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement