You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "Xiaowhyyan (GitHub)" <gi...@apache.org> on 2018/09/30 11:56:38 UTC

[GitHub] [incubator-dubbo] Xiaowhyyan opened issue #2590: dubbo发布http服务后 http客户端访问问题

你好
我这边写一个dubbo provider 发布服务为http协议
配置为
<dubbo:application name="demo-provider"/>
    <!-- use multicast registry center to export service -->
    <dubbo:registry protocol="zookeeper" address="192.168.4.105:2181" />
    <!-- use dubbo protocol to export service on port 20880 -->
    <dubbo:protocol name="dubbo" port="20880"/>
    <dubbo:protocol name="http" port="20991"/>
    <!-- service implementation, as same as regular local bean -->
    <bean id="demoService" class="com.why.Impl.UserInterImpl"/>
    <!-- declare the service interface to be exported -->
    <dubbo:service interface="com.why.jiekou.UserInter" ref="demoService" protocol="dubbo,http"/>

然后服务启动正常以后

客户端如何去往com.why.jiekou.UserInter接口发请求
UserInter接口下面方法如下
String test();
String sayHello(String name);
UserResponse zhuce(User user) throws ClassNotFoundException, SQLException;

比如如何往此接口 sayHello方法发http请求,报文格式是怎么样的?

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2590 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] Xiaowhyyan commented on issue #2590: dubbo发布http服务后 http客户端访问问题

Posted by "Xiaowhyyan (GitHub)" <gi...@apache.org>.
你好 很高兴你能回复
你这边给的答案
1、https://github.com/apache/incubator-dubbo/tree/master/dubbo-demo 这个是讲解如何使用dubbo 发布dubbo接口 如何写provider  consumer客户端 这个我是清楚的
2、http://dubbo.apache.org/zh-cn/docs/user/quick-start.html 这个文档里 有说明如何让dubbo发布http服务 我这边已经发布出来了 
<dubbo:protocol name="http" port="20991"/>

我再阐述下我的问题哈
我的问题是: 我使用dubbo框架发布http协议接口(注意不是dubbo协议)
http接口发布以后,客户端如何调用已经发布的http协议接口

官网上没有看到范例,所以我就去找dubbo的这个测试代码 路径为
incubator-dubbo/dubbo-rpc/dubbo-rpc-http/src/test/java/org/apache/dubbo/rpc/protocol/http/HttpProtocolTest.java

而这块测试代码也是采用的dubbo自身的api 类来发送http请求
如:
 @Test
    public void testHttpProtocol() {
        HttpServiceImpl server = new HttpServiceImpl();
        Assert.assertFalse(server.isCalled());
        ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
        Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
        URL url = URL.valueOf("http://127.0.0.1:5342/" + HttpService.class.getName() + "?version=1.0.0");
        Exporter<HttpService> exporter = protocol.export(proxyFactory.getInvoker(server, HttpService.class, url));
        Invoker<HttpService> invoker = protocol.refer(HttpService.class, url);
        HttpService client = proxyFactory.getProxy(invoker);
        String result = client.sayHello("haha");
        Assert.assertTrue(server.isCalled());
        Assert.assertEquals("Hello, haha", result);
        invoker.destroy();
        exporter.unexport();
    }


但是我想用 比如postman往dubbo http接口上发请求 ,以com.why.jiekou.UserInter接口 String sayHello(String name)方法为例

请求的path路径是什么样的? 报文格式是什么样的?

麻烦啦

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2590 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] beiwei30 closed issue #2590: dubbo发布http服务后 http客户端访问问题

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
[ issue closed by beiwei30 ]

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2590 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] kimmking commented on issue #2590: dubbo发布http服务后 http客户端访问问题

Posted by "kimmking (GitHub)" <gi...@apache.org>.
you can refer to dubbo-demo
or
read  http://dubbo.apache.org/zh-cn/docs/user/quick-start.html

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2590 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] kimmking commented on issue #2590: dubbo发布http服务后 http客户端访问问题

Posted by "kimmking (GitHub)" <gi...@apache.org>.
you can read dubbo-demo

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2590 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] kimmking commented on issue #2590: dubbo发布http服务后 http客户端访问问题

Posted by "kimmking (GitHub)" <gi...@apache.org>.
Dubbo HTTP protocol is a wrap of spring remoting httpinvoker.
You can call it directly by spring remoting httpinvoker.

See also https://github.com/apache/incubator-dubbo/blob/master/dubbo-rpc/dubbo-rpc-http/src/main/java/org/apache/dubbo/rpc/protocol/http/HttpProtocol.java


[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2590 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] kimmking commented on issue #2590: dubbo发布http服务后 http客户端访问问题

Posted by "kimmking (GitHub)" <gi...@apache.org>.
It is dependent on how do you defind a Service:
- a backend service is a Service
- or a proxy service is a Service

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2590 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] gudegg commented on issue #2590: dubbo发布http服务后 http客户端访问问题

Posted by "gudegg (GitHub)" <gi...@apache.org>.
You can use the rest protocol if you use postman . The http protocol  base on Spring's HttpInvoker(POST) and the  java serialization. see https://dubbo.incubator.apache.org/en-us/docs/user/references/protocol/http.html

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2590 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] kimmking commented on issue #2590: dubbo发布http服务后 http客户端访问问题

Posted by "kimmking (GitHub)" <gi...@apache.org>.
you can refer to https://github.com/apache/incubator-dubbo/tree/master/dubbo-demo
or
read  http://dubbo.apache.org/zh-cn/docs/user/quick-start.html

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2590 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org