drop0118 2011-03-30 17:27:54 10581次浏览 22条回复 0 0 0

我是按照官方说明一步一步的做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

  • 回复于 2011-11-15 16:51 举报

    遇到相同的问题,文件修改后第一次访问可以看到里面的方法,刷新后就消失了,让后再修改依然如故,把demo的phonebook原封不动放到根目录测试也是不行,难道是配置问题,确定开启了soap 难道是php 5.2.6的bug,求解!!

  • 回复于 2011-04-06 13:36 举报

    这里有个奇怪的现象,每当我对webservice服务端的程序进行改动之后,第一次访问这个页面WSDL中就有函数方法描述
    ,但是刷新一次就没有了,不知道是为什么。

  • 回复于 2011-04-02 18:18 举报

    如果正确,你的WSDL中应该有你的函数方法描述,现在看你的WSDL中没有,说明路径或定义出了问题,不用调别的,首先保证WSDL输出正确,其他的不用看先。

  • 回复于 2011-04-02 13:48 举报

    这个我有注意到呢···路径全部都是正确的···要不然报的错也不是这个了···

  • 回复于 2011-04-02 13:27 举报
    $client=new SoapClient('http://hostname/path/to/index.php?r=stock/quote');
    

    应为:

    $client=new SoapClient('http://hostname/path/to/index.php?r=web/quote');
    
  • 回复于 2011-04-02 09:30 举报

    呃···这是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');
    
  • 回复于 2011-04-01 18:01 举报

    需要看看你的代码是怎么写的,接口类的完整代码。

  • 回复于 2011-04-01 15:21 举报

    就没有人使用过Yii的webservice功能吗?

  • 回复于 2011-04-01 14:23 举报

    好深奥.....以前学过,不过工作中还没用到过,没怎么专门研究过!~

  • 回复于 2011-03-31 17:27 举报

    我才接触这个东西,完全一片迷茫呀···我就是按照教程来做的···:(

  • 回复于 2011-03-31 16:42 举报

    看你的WSDL中也没有getPrice这个方法的定义,所以应该是定义出错了。

  • 回复于 2011-03-31 16:32 举报

    那就是这个方法定义的有问题,看出错信息是这样的。你可以试试调用其他的方法试试,如果就这个不行,就是这个方法定义的问题,如果都不行,那不是路径写错了,就是soap用的不对。

  • 回复于 2011-03-31 15:54 举报

    应该不是缓存问题吧···第一次就报错了

  • 回复于 2011-03-31 12:09 举报

    可能是SOAP缓存问题,清下缓存试试。

    ini_set(“soap.wsdl_cache_enabled”, “0″);
    
  • 回复于 2011-03-31 10:05 举报
    <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>
    
  • 回复于 2011-03-31 09:29 举报

    你的WSDL返回值是什么?

  • 回复于 2011-03-31 09:12 举报
  • 回复于 2011-03-30 18:29 举报

    stock/quote 这里有个方法 有问题, 字面是这样 我不太会soap 所以帮不上..

  • 回复于 2011-03-30 18:17 举报
  • 回复于 2011-03-30 18:17 举报

    你确定PHP的SOAP开启了么 = =

您需要登录后才可以回复。登录 | 立即注册