`
lan13217
  • 浏览: 483053 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

YII webservics not persent

 
阅读更多

php.ini 

 

; Enables or disables WSDL caching feature.

; http://php.net/soap.wsdl-cache-enabled

soap.wsdl_cache_enabled=0

 

php netbeans debug

https://netbeans.org/kb/docs/php/debugging_zh_CN.html

 

yii webservice(document/literal encoding for WDSL)

https://github.com/yiisoft/yii/issues/94

https://github.com/nineinchnick/yii/commit/a61b6de16ef4044230cca6f54f241ede6b9b5705

 

<?php

class StockController extends CController
{
    public function actions()
    {
        /*
        return array(
            'quote'=>array(
                'class'=>'CWebServiceAction',
            ),
        );*/
        return array(
            'wsdl'=>array(
                'class'=>'CWebServiceAction',
                'serviceOptions' => array(
                    'generatorConfig' => array(
                        'class' => 'CWsdlGenerator',
                        'operationBodyStyle'=>array('use'=>'literal'),
                        'bindingStyle'=>'document',
                    ),
                ),
            ),
        );
    }

    /**
     * @param string the symbol of the stock
     * @return float 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
    }
    public function actionView()
    {
        return "ss"
    }
}

 http://stackoverflow.com/questions/1523460/ensuring-valid-utf-8-in-php

<?php

class StockController extends CController
{
    public function actions()
    {
        /*
        return array(
            'quote'=>array(
                'class'=>'CWebServiceAction',
            ),
        );*/
        return array(
            'wsdl'=>array(
                'class'=>'CWebServiceAction',
                'serviceOptions' => array(
                    'generatorConfig' => array(
                        'class' => 'CWsdlGenerator',
                        'operationBodyStyle'=>array('use'=>'literal'),
                        'bindingStyle'=>'document',
                    ),
                ),
            ),
        );
    }

    /**
     * @param string the symbol of the stock
     * @return float 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
    }
    /**
     * @param string the symbol of the stock
     * @return string the stock price
     * @soap
     */
    public function createPost($symbol)
    {       
        echo $symbol;
        $model=new Post;
        $model->title='title';
        $model->content='content';
        $model->status=2;
        $model->create_time=1230952187; 
        $model->update_time=1230952187; 
        $model->author_id=1; 
        $model->tags='test';
        if($model->save()){
            return '添加一条记录';
        }else{
            return '添加失败';
        }
    }
    /**
     * @param string the symbol of the stock
     * @return string the stock price
     * @soap
     */
    public function sendPost($symbol)
    {       
        $data=base64_decode($symbol);
        $temp=bzdecompress($data);
        $megObject = json_decode(make_safe_for_utf8_use($temp),true);
        $posts = json_decode($megObject['dataBody'],true); 
        //if(gettype($megObject['dataBody'])=="string"){
        //}
        //return gettype($posts);
        $postSucces=0;
        $postFaile=0;
        foreach($posts as $value)
        {
            //return $value;
            //return $value["title"];
            $model=new Post;
            $model->title=$value["title"];
            $model->content=$value["content"];
            $model->tags=$value["tags"];
            $model->create_time=$value["create_time"]; 
            $model->update_time=$value["update_time"]; 
            $model->status=$value["status"];
            $model->author_id=$value["author_id"];
            if($model->save()){
                $postSucces++;
            }else{
                $postFaile++;
            }
         }
        return "postSucces:".$postSucces.";postFaile".$postFaile;
    }
    public function actionView()
    {       
        $model=new Post;
        $model->title='title';
        $model->content='content';
        $model->tags='test';
        $model->create_time=1230952187; 
        $model->update_time=1230952187; 
        $model->status=2;
        $model->author_id=1;
        if($model->save()){
            echo '添加一条记录';
        }else{
            echo '添加失败';
        }
    }
    public function actionShow()
    {   
        $msg="{\"dataBody\":\"[{\\\"author_id\\\":100,\\\"content\\\":\\\"mytitle0\\\",\\\"create_time\\\":1389071330977,\\\"id\\\":0,\\\"status\\\":1,\\\"tags\\\":\\\"110\\\",\\\"title\\\":\\\"mytitle你好0\\\",\\\"update_time\\\":0},{\\\"author_id\\\":101,\\\"content\\\":\\\"mytitle1\\\",\\\"create_time\\\":1389071330977,\\\"id\\\":1,\\\"status\\\":1,\\\"tags\\\":\\\"110\\\",\\\"title\\\":\\\"mytitle你好1\\\",\\\"update_time\\\":0},{\\\"author_id\\\":102,\\\"content\\\":\\\"mytitle2\\\",\\\"create_time\\\":1389071330977,\\\"id\\\":2,\\\"status\\\":1,\\\"tags\\\":\\\"110\\\",\\\"title\\\":\\\"mytitle你好2\\\",\\\"update_time\\\":0},{\\\"author_id\\\":103,\\\"content\\\":\\\"mytitle3\\\",\\\"create_time\\\":1389071330977,\\\"id\\\":3,\\\"status\\\":1,\\\"tags\\\":\\\"110\\\",\\\"title\\\":\\\"mytitle你好3\\\",\\\"update_time\\\":0},{\\\"author_id\\\":104,\\\"content\\\":\\\"mytitle4\\\",\\\"create_time\\\":1389071330977,\\\"id\\\":4,\\\"status\\\":1,\\\"tags\\\":\\\"110\\\",\\\"title\\\":\\\"mytitle你好4\\\",\\\"update_time\\\":0},{\\\"author_id\\\":105,\\\"content\\\":\\\"mytitle5\\\",\\\"create_time\\\":1389071330977,\\\"id\\\":5,\\\"status\\\":1,\\\"tags\\\":\\\"110\\\",\\\"title\\\":\\\"mytitle你好5\\\",\\\"update_time\\\":0},{\\\"author_id\\\":106,\\\"content\\\":\\\"mytitle6\\\",\\\"create_time\\\":1389071330977,\\\"id\\\":6,\\\"status\\\":1,\\\"tags\\\":\\\"110\\\",\\\"title\\\":\\\"mytitle你好6\\\",\\\"update_time\\\":0},{\\\"author_id\\\":107,\\\"content\\\":\\\"mytitle7\\\",\\\"create_time\\\":1389071330977,\\\"id\\\":7,\\\"status\\\":1,\\\"tags\\\":\\\"110\\\",\\\"title\\\":\\\"mytitle你好7\\\",\\\"update_time\\\":0},{\\\"author_id\\\":108,\\\"content\\\":\\\"mytitle8\\\",\\\"create_time\\\":1389071330977,\\\"id\\\":8,\\\"status\\\":1,\\\"tags\\\":\\\"110\\\",\\\"title\\\":\\\"mytitle你好8\\\",\\\"update_time\\\":0},{\\\"author_id\\\":109,\\\"content\\\":\\\"mytitle9\\\",\\\"create_time\\\":1389071330977,\\\"id\\\":9,\\\"status\\\":1,\\\"tags\\\":\\\"110\\\",\\\"title\\\":\\\"mytitle你好9\\\",\\\"update_time\\\":0}]\",\"sendTime\":1389071331061,\"type\":\"list\"}";
        //echo $msg;
        $megObject = json_decode($msg);
        //echo $megObject->dataBody;
        $posts = json_decode($megObject->dataBody);
        foreach($posts as $value)
        {
            echo $value->title;
            $model=new Post;
            $model->title=$value->title;
            $model->content=$value->content;
            $model->tags=$value->tags;
            $model->create_time=$value->create_time; 
            $model->update_time=$value->update_time; 
            $model->status=$value->status;
            $model->author_id=$value->author_id;
            $model->save();
         }
//        $model=new Post;
//        $model->title='title';
//        $model->content='content';
//        $model->tags='test';
//        $model->create_time=1230952187; 
//        $model->update_time=1230952187; 
//        $model->status=2;
//        $model->author_id=1;
//        if($model->save()){
//            echo '添加一条记录';
//        }else{
//            echo '添加失败';
//        }
    }
        
}
function make_safe_for_utf8_use($string) {
    if (preg_match('%^(?:
          [\x09\x0A\x0D\x20-\x7E]            # ASCII
        | [\xC2-\xDF][\x80-\xBF]             # non-overlong 2-byte
        | \xE0[\xA0-\xBF][\x80-\xBF]         # excluding overlongs
        | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
        | \xED[\x80-\x9F][\x80-\xBF]         # excluding surrogates
        | \xF0[\x90-\xBF][\x80-\xBF]{2}      # planes 1-3
        | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
        | \xF4[\x80-\x8F][\x80-\xBF]{2}      # plane 16
    )*$%xs', $string))
        return $string;
    else
        return iconv('gbk', 'UTF-8', $string);
}

 

分享到:
评论

相关推荐

    yii框架yii框架yii框架yii框架yii框架

    很好用yii框架很好用yii框架很好用yii框架很好用yii框架很好用yii框架很好用yii框架很好用yii框架很好用yii框架很好用yii框架很好用yii框架很好用yii框架很好用yii框架很好用yii框架

    Yii2.0打造京东商城平台PHP电商实战Yii2.0视频教程

    Yii2.0级基于Yii1.X完全重写的,不仅是小版本升级的升级。所以想要系统学习Yii2.0这个框架这套教程可以从实战项目带你入手。不错的学习YII框架的基础课程,电商系统的结构完整、框架资源太大,传百度网盘了,链接在...

    深入理解Yii2.0

    《深入理解Yii2.0》是一本干货。主要讲解Yii2.0及所代表的最新一代Web开发框架的新特性、新技术、新理念、新模式。 采用的方式是分析框架的源代码,尝试从根上进行理解和阐述,并融入个人使用Yii开发的一些经验和...

    yii framework(Yii)框架window版

    Yii采用严格的OOP编写,并有着完善的库引用以及全面的教程。从 MVC,DAO/ActiveRecord,widgets,caching,等级式RBAC,Web服务,到主题化,I18N和L10N,Yii提供了今日Web 2.0应用开发所需要的几乎一切功能。事实上...

    yii1.1.10 开发包(包含yii权威指南以及yii博客例子讲解)

    yii1.1.10 开发包(包含yii权威指南以及yii博客例子讲解)

    Yii权威指南思维导图

    Yii权威指南思维导图 yii类结构 类导图 权威指南

    Yii 中文帮助文档

    Yii 是什么 Yii 是一个基于组件、用于开发大型 Web 应用的高性能 PHP 框架。它将 Web 编程中的可重用性发挥到极致,能够显著加速开发进程。Yii(读作“易”)代表简单(easy)、高效(efficient)、可扩展(extensible)。...

    Mastering Yii.pdf(en)

    Yii Framework 2 (Yii2) is the successor to the popular Yii framework. Like its successor, Yii2 is an open source, high-performance rapid development framework designed to create modern, scalable, ...

    Yii2参考手册-新

    Yii2参考手册,Yii2中文手册完整版

    yii框架中文手册教程和YII模板

    yii框架中文手册教程和YII模板 我很辛苦才找到的

    YII多种缓存机制

    YII 多种缓存机制的运用 如文件缓存内存缓存 动态缓存等

    yii2swoole让yii2运行在swoole上

    yii2 swoole:让yii2运行在swoole上 , 运行在swoole上的yii2是运行在php-fpm上yii2的5倍以上

    yii框架中文文档、yii中文手册教程

    yii1.1中文文档 yii框架中文手册教程.pdf

    yii framework框架 + yii app模板(基本、高级).zip

    yii framework框架 + yii app模板(基本、高级)

    yii的小部件使用

    yii的小部件使用的总结,快速生成增删改查,感觉不同的需求进行逻辑修改!

    Yii2中文手册(完整版).zip

    Yii采用严格的OOP编写,并有着完善的库引用以及全面的教程。从 MVC,DAO/ActiveRecord,widgets,caching,等级式RBAC,Web服务,到主题化,I18N和L10N,Yii提供了今日Web 2.0应用开发所需要的几乎一切功能。事实上...

    新下载的yii2,yii framework

    刚下载的yii2,新下载的yii2

    php开发yii框架软件包

    yii框架yii框架yii框架yii框架yii框架yii框架yii框架yii框架yii框架yii框架yii框架yii框架yii框架yii框架yii框架yii框架yii框架yii框架

    yii-1.1.8.r3324

    yii-1.1.8.r3324

    Yii 的登录流程

    Yii是一个全栈式的MVC框架,所谓全栈式指的是Yii框架本身实现了web开发中所要用到的所有功能,比如MVC,ORM(DAO/ActiveRecord), 全球化(I18N/L10N), 缓存(caching), 基于jQuery Ajax支持(jQuery-based AJAX support), ...

Global site tag (gtag.js) - Google Analytics