Chinaunix

标题: php5的soap怎么用 [打印本页]

作者: 轩辕砍刀    时间: 2007-04-26 10:34
标题: php5的soap怎么用
想用php5的soap库调.net的web service,请大大们给个详细简单的例子~
作者: kongge_1    时间: 2007-04-27 17:32
标题: .net的web service没有,google的到做过
作了一个调用google的web service代码如下:



  1. $query = '上海';
  2. $key = 'CMDusl5QFHIEnwCvJKbCPgFOOMxzoiJy';
  3. $num = 10;


  4. //$soapoptions = array('namespace' => 'urn:GoogleSearch',
  5. //'trace' => 0);

  6. $soap_client= new SoapClient("http://api.google.com/GoogleSearch.wsdl",$soapoptions);
  7. print"<pre>";


  8. $params = array(
  9. 'key' => $key, // the Developer's key
  10. 'q' => $query, // the search query
  11. 'start' => 0, // the point in the search results should Google start
  12. 'maxResults' => 10, // the number of search results (max 10)
  13. 'filter' => false, // should the results be filtered?
  14. 'restrict' => 'countryCN',
  15. 'safeSearch' => false,
  16. 'lr' => 'lang_zh-CN',
  17. 'ie' => '',
  18. 'oe' => ''
  19. );



  20. $response=$soap_client->__soapCall("doGoogleSearch",$params);

  21.   //echo $soap_client->__getLastRequest()."\n";
  22.   //echo $soap_client->__getLastResponse()."\n";
  23.   //var_dump($response);


  24. for($i=0;$i<$num;$i++)
  25. {
  26. $res[] = $soap_client->__soapCall("doGoogleSearch",$params);
  27. $i++;
  28. }
  29. print_r($res);


  30. //$soap_client->doGoogleSearch();
  31. //var_dump($soap_client->__getTypes());

复制代码

作者: 轩辕砍刀    时间: 2007-04-28 17:47
多谢,学习了!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2