Yii 的Web Service的一个问题,求解! [ 新手入门 ]
我是按照官方说明一步一步的做Web Service 但是当我用
$client=new SoapClient('http://hostname/path/to/index.php?r=stock/quote');
echo $client->getPrice('GOOGLE');
去访问我这个webservice的时候出现如下错误,如何解决啊! Fatal error: Uncaught SoapFault exception: [Client] Function ("getPrice") is not a valid method for this service in E:\wamp\www\index.php:3 Stack trace: #0 [internal function]: SoapClient->__call('getPrice', Array) #1 E:\wamp\www\index.php(3): SoapClient->getPrice('GOOGLE') #2 {main} thrown in E:\wamp\www\index.php on line 3
共 22 条回复
-
应该是你的webservice文件'http://hostname/path/to/index.php?r=stock/quote'的错误。
-
SOAP已经开启了···用网页访问http://hostname/path/to/index.php?r=stock/quote有WSDL返回值的
-
<definitions name="WebController" targetNamespace="urn:WebControllerwsdl"> <wsdl:portType name="WebControllerPortType"/> − <wsdl:binding name="WebControllerBinding" type="tns:WebControllerPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> </wsdl:binding> − <wsdl:service name="WebControllerService"> − <wsdl:port name="WebControllerPort" binding="tns:WebControllerBinding"> <soap:address location="http://192.168.1.114/yii/blog/web/quote.shtml?ws=1"/> </wsdl:port> </wsdl:service> </definitions>
-
呃···这是WebController.php的代码
<?php class WebController extends Controller { public function actions() { return array( 'quote'=>array( 'class'=>'CWebServiceAction', ), ); } /** * @param string the symbol of the stock * @return string the stock price * @soap */ public function getPrice($symbol) { $prices=array('IBM'=>100, 'GOOGLE'=>350); return isset($prices[$symbol])?$prices[$symbol]:0; //...return stock price for $symbol } /** * * @return string * @soap */ public function test() { return "test"; } }
然后客户端的代码就是官方的写法
$client=new SoapClient('http://hostname/path/to/index.php?r=stock/quote'); echo $client->getPrice('GOOGLE');
drop0118
注册时间:2011-03-29
最后登录:2013-10-18
在线时长:0小时0分
最后登录:2013-10-18
在线时长:0小时0分
- 粉丝0
- 金钱160
- 威望0
- 积分160