xhanthow edited a comment on issue #2577:
URL:
https://github.com/apache/servicecomb-java-chassis/issues/2577#issuecomment-920502909
> 你使用的是哪个版本? 你描述的行为貌似是1.x版本的。 2.x版本 test1 应该返回 test.Response.
用的的确是1.X的版本, 而且 test1 的确应该返回 test.Response,但是我的意思是,test1()的返回值只要和
test.Response的内容一样就行,无论命名怎么,包路径怎样。但是是因为cse包装的restTemplate最终会走到这个方法org.springframework.web.client.CseHttpMessageConverter#read(Class<?
extends Object> clazz,
HttpInputMessage
inputMessage),但是该方法并没有使用到clazz这个参数,导致其返回结果就是对方服务所定义的响应体。所以调用方定义的响应体就必须和服务方完全保持一致(包路径+类名)。而使用rpc注解的时候,会走到org.apache.servicecomb.provider.pojo.Invoker#syncInvoke,然后里面有个这个操作consumerOperation.getResponseMapper().mapResponse(response),即会把对方服务方的响应体转换为我们自己定义的(服务方和调用方响应体的内容相同即可)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]