You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/09/14 03:45:17 UTC

[GitHub] [servicecomb-java-chassis] xhanthow opened a new issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

xhanthow opened a new issue #2577:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2577


   我想在CseHttpMessageConverter中增加一些逻辑,有扩展的口子么?或者修改CseRestTemplate的口子么?


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] xhanthow commented on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
xhanthow commented on issue #2577:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2577#issuecomment-919724851


   > 你的意思不是很理解,貌似 java-chassis 是支持的。 从使用者的角度, 能否举一个简单的代码例子?
   
   ```java
   private final RestTemplate restTemplate = RestTemplateBuilder.create();
   
   @RpcReference(microserviceName = "testDemo", schemaId = "xx")
   private TestApi testApi;
   
   @Test
   public void test1() {
       Response response = restTemplate.getForObject("url", Response.class);
       System.out.println(response);
   }
   
   @Test
   public void test2() {
       Response response = testDemo.test("ids");
       System.out.println(response);
   }
   ```
   testDemo服务的test方法定义的返回值为test.Response,但是调用方如test1(),test2()中返回的Response路径为local.Response,那么这个时候test1()会报castexception,但是test2()是ok的


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] fanjiang-2021 commented on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
fanjiang-2021 commented on issue #2577:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2577#issuecomment-918853298


   感觉CseRestTemplate是否可以基于SPI机制重构一下 提供HttpMessageConverter扩展能力 @liubao68 


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2577:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2577#issuecomment-919051664


   你的意思不是很理解,貌似 java-chassis 是支持的。 能否举一个简单的代码例子? 


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #2577:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2577#issuecomment-919051664


   你的意思不是很理解,貌似 java-chassis 是支持的。 从使用者的角度, 能否举一个简单的代码例子? 


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] xhanthow commented on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
xhanthow commented on issue #2577:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2577#issuecomment-918855295


   > 感觉CseRestTemplate是否可以基于SPI机制重构一下 提供HttpMessageConverter扩展能力 @liubao68
   
   现在有办法扩展下CseHttpMessageConverter么?


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] xhanthow closed issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
xhanthow closed issue #2577:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2577


   


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] xhanthow edited a comment on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] xhanthow edited a comment on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2577:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2577#issuecomment-920493525


   你使用的是哪个版本? 你描述的行为貌似是1.x版本的。 2.x版本 test1 应该返回 test.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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] xhanthow commented on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
xhanthow commented on issue #2577:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2577#issuecomment-919041253


   > 需要描述下业务诉求。 技术实现方面, 这个是不提供扩展的,这个从java-chassis角度就是实现, 为了适配spring的开发习惯。
   
   主要就是为了适配使用RestTemplate调用接口时,调用方的响应体得和服务方的保持路径和类名一致。而不是像用注解那样,只要类中的属性保持一致就行


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] xhanthow commented on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
xhanthow commented 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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2577:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2577#issuecomment-919013425


   需要描述下业务诉求。 技术实现方面, 这个是不提供扩展的,这个从java-chassis角度就是实现, 为了适配spring的开发习惯。 


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2577: 可以修改CseHttpMessageConverter里的逻辑么?

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2577:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2577#issuecomment-920698910


   升级2.x即可


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org