php soap客户端调试实例及调试
1,实例
1.try { 2. $client = new SoapClient( 3. null, 4. array('location' =>'http://localhost/oms07/index.php?r=api', 5. 'uri' =>'http://localhost/oms07') 6. ); 7. $results = $client->__soapCall('getFailParts', array('startTime'=>'2011-10-24','endTime'=>'2011-10-25')); 8. var_dump($result); 9. } catch (Exception $e) { 10. printf("Message = %s",$e->__toString()); 11. }
2,调试
SOAP扩展当前已经提供调试功能,
“之前在使用soap时,调试时无法得知返回错误信息,只会得到looks like
we got no XML document。最近还想写个扩展用于获取返回响应信息,再查看PHP文档原来可以这样.手册是个好东西。”
PHP代码
1./** 2.* 设置参数array("trace"=>true)用于调试 3.* __getLastRequest 返回请求信息 4.* __getLastResponse 返回响应信息包括报错信息都会返回 5.*/ 6.try{ 7. $client = new SoapClient($server,array("trace"=>true)); 8. $client->method($args); 9.}catch(SoapFault $e){ 10. echo $client->__getLastRequest(); 11. echo $client->__getLastResponse(); 12. echo $e->getMessage(); 13.}