web services - PHP SOAP Extension with WSDL throwing Headers already sent -


acknowledging fact question has been asked number of times , haven't come across solution close situation left no option post own query.

below simple class wrote convert wsdl file through php2wsdl library.

class myclass {   /**    * adds 2 numbers.    *    * @soap    *    * @param float $p1    * @param float $p2    * @return float   */   public function getsum($num1, $num2){      return $num1 + $num2;     }  } 

i have includexd below image of wsdl file due formatting issues might typing here apologies:

enter image description here

i have client query service not sure doing wrong. aware of existing libraries such zend_autodiscovery , stuff want understand concepts behind php soap scratch.

require_once __dir__ . '/../../../php2wsdl.php'; ini_set('default_socket_timeout', 600);  try {    $client = new \soapclient(__dir__ . '/../input/myclass.wsdl', array(      'connection_timeout'=>5,      'trace'=>true,      'soap_version'=>soap_1_2    ));   $myclass = new \myclass();   /* var_dump($client->__getfunctions());  exit();*/   $result =  $client->__soapcall('getsum', array('myclass' => $class, 'num1' => 17, 'num2' => 5));  printf("result = %s\n", $result);  } catch (exception $e) {   printf("message = %s\n",$e->__tostring()); } 

warning: uncaught soapfault exception: [http] error fetching http headers in d:\web\webserv-bundle\web\services\process\myclass_client.php:19 stack trace: #0 [internal function]: soapclient->__dorequest('http://localhos...', 'http://localhos...', 2, 0) #1 d:\web\webserv-bundle\web\services\process\myclass_client.php(19): soapclient->__soapcall('getsum', array) #2 d:\web\webserv-bundle\web\services\index.php(3): require_once('d:\web\webserv-...') #3 {main} thrown in d:\web\webserv-bundle\web\services\process\myclass_client.php on line 19

you should increase socket timeout.

in php.ini file,

default_socket_timeout = 480 

also change true 1,

'trace'=>1 

hope :)


Comments