Giter Site home page Giter Site logo

hprose 结合tp5怎么使用 about hprose-php HOT 8 CLOSED

hprose avatar hprose commented on May 3, 2024
hprose 结合tp5怎么使用

from hprose-php.

Comments (8)

Hongic avatar Hongic commented on May 3, 2024 3

hprose 整个thinkphp 5.0 已经解决。步骤大概如下:
服务端:1、tp5的控制器的方法里面注册模型(比如:model)里面的类或方法,控制器里面不能有tp的任何return,浏览器访问url地址时,只能看到hprose服务端指定格式的输出,不能看到自己的业务返回值输出,否则客户端调用会报错;
2、route 重新构造http路由,客户端访问的时候就是访问这个url的。
服务端:直接在控制器里面实例化hprose客户端,注意客户端的url,要跟服务器指定的路由一致,不然会报错,然后根据返回值写自己的业务逻辑。

from hprose-php.

andot avatar andot commented on May 3, 2024

一般报告 Wrong Response 错误有两种情况:

1、PHP 文件有 BOM 头,这样会让返回的响应包含 BOM 头,导致返回的响应不正确,这种情况去掉 BOM 头就行了。
2、PHP 中在 Hprose 的响应输出之后,还有其它多余的输出,一般有些框架是用来输出 html 的,通常在输出页面的最后会输出一些调试信息,这些信息对于 html 页面的显示没有影响,但是对于返回纯数据的情况下,会导致结果无法被解析。所以,你可以检查一下你的框架有没有输出这些调试信息,如果有的话,关掉就可以了。

from hprose-php.

Hongic avatar Hongic commented on May 3, 2024

在浏览器输入服务端地址看到的是json数据,但是在客户端请求的时候就Wrong Response,还有json数据

from hprose-php.

andot avatar andot commented on May 3, 2024

hprose 的返回结果不应该有 json 数据。

from hprose-php.

Hongic avatar Hongic commented on May 3, 2024

hprose 客户端是不是只能返回服务端的Fa3{u#s5"index"s2"cc"}z,这样的信息?

from hprose-php.

andot avatar andot commented on May 3, 2024

这个信息是浏览器访问的时候返回的,如果是 hprose 客户端进行调用,返回数据参见rpc 应答

from hprose-php.

Hongic avatar Hongic commented on May 3, 2024

但是thinkphp框架限定,每一个http请求的url都是有返回值的,客户端使用的url的时候就会有返回值,然后就报错了

from hprose-php.

andot avatar andot commented on May 3, 2024

hprose 只需要一个入口就行了,服务方法不需要写在控制器中,发布服务的方法不需要写返回值就可以了。

from hprose-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.