weibocom / motan

A cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.
Other
5.88k stars 1.78k forks source link

新出的restful协议能不能提供个完整事例 #522

Open chenshijun007 opened 7 years ago

chenshijun007 commented 7 years ago

根据现在的事例配置会报错,有一定的问题,如: 示例描述的

此时如果使用rpc客户端,则需要注意contextpath配置:, 假如服务端部署的ContextPath为/myserver,servlet的url-pattern为/servlet/*,则客户端的contextpath则应配置为/myserver/servlet

会报如下错误:

Offending resource: class path resource [spring/spring-core.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 7 in XML document from URL [file:/......./WEB-INF/classes/motan/motan-client.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 69; cvc-complex-type.3.2.2: 元素 'motan:protocol' 中不允许出现属性 'contextpath'
rayzhang0603 commented 7 years ago

感谢反馈。文档需要修改一下,目前不支持配置web服务器的contextpath,在接口的@Path注解中配置uri就可以。 可以参考motan/motan-extension/protocol-extension/motan-protocol-restful模块下的/src/test/java/com/weibo/api/motan/protocol/restful/TestRestful.java 使用xml配置时,server和client端都配置endpointFactory="netty"就可以了

chenshijun007 commented 7 years ago

关于restful配置server.xml的问题:如下 在示例:/src/test/java/com/weibo/api/motan/protocol/restful/TestRestful.java里边 有serviceConfig.setProtocol(protocolConfig)这个配置,将其配置在server.xml中的 怎么配置。

rayzhang0603 commented 7 years ago

@chenshijun007 已经增加了restful的demo,稍后会合并到主干。你可以先参考addRestfulDemo分支中demo模块的RestfulServerDemo、RestfulClient