简体   繁体   English

Apache CXF中的SOAP over WebSockets?

[英]SOAP over WebSockets in Apache CXF?

Does CXF support WebSockets as a transport protocol? CXF是否支持WebSockets作为传输协议?

I need to support multiplexed SOAP and WebSocket protocol looks perfect as a starting point. 我需要支持多路复用SOAP和WebSocket协议看起来很完美作为起点。 It is a bidirectional and full duplex protocol. 它是双向和全双工协议。 By multiplexing I mean that the client can send messages without waiting for the response, and the responses may be sent back in the different order that they were sent (I will use message / conversation ID, to identify the request and response) 通过多路复用我的意思是客户端可以在不等待响应的情况下发送消息,并且响应可以按照它们被发送的不同顺序发回(我将使用消息/对话ID来识别请求和响应)

It should be very similar to JMS where CXF can receive requests and send responses asynchronously and in any order eg: 它应该非常类似于JMS,其中CXF可以接收请求并以任何顺序异步发送响应,例如:

I looked for the information in the mailing list history, but it's still not clear for me if CXF supports WebSocket out-of-the box or I need to implement my own transport ? 我查找了邮件列表历史记录中的信息,但是如果CXF支持开箱即用的WebSocket或者我需要实现自己的传输 ,我仍然不清楚这一点?

The question I asked is still valid, but there is one answer that satisfies me :) 我问的问题仍然有效,但有一个答案让我满意:)

Instead of java.util.concurrent queues I can simply use JMS. 我可以简单地使用JMS代替java.util.concurrent队列。 Then, depending on the context and scalability requirements I can use in-jvm queue or distributed queues. 然后,根据上下文和可伸缩性要求,我可以使用in-jvm队列或分布式队列。 In such case CXF is already supporting SOAP over JMS . 在这种情况下,CXF已经支持SOAP over JMS

What needs to be ensured is to have a queue per WebSocket connection (or one can use JMS Message Selector ). 需要确保的是每个WebSocket连接有一个队列(或者可以使用JMS消息选择器 )。 It's because the response to the request that was received by WebSocket A MUST be sent back with the same connection. 这是因为WebSocket A收到的对请求的响应必须使用相同的连接发回。

Hi a bit late answer I guess, but it seems as Soap over Websocket is supported in CXF. 嗨,有点迟到的答案我猜,但似乎在CXF支持Soap over Websocket。 The main problem configuring it is getting the correct netty dependencies in place which is not properly described on CXF web site. 配置它的主要问题是获得正确的网络依赖关系,这在CXF网站上没有正确描述。 The list of dependencies that worked for me is described in the following post: 以下文章描述了对我有用的依赖项列表:

SOAP over Websocket with Appache CXF and Embedded Jetty 使用Appache CXF和Embedded Jetty的SOAP over Websocket

The post contains a working example of CXF soap endpoint using websocket transport. 该帖子包含使用websocket传输的CXF soap端点的工作示例。

I will summarize the nessesary dependencies that will make it work: 我将总结将使其工作的必要依赖项:

<dependency>
            <groupId>org.asynchttpclient</groupId>
            <artifactId>async-http-client</artifactId>
            <version>2.0.39</version>
             <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-buffer</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-codec-http</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-handler</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-transport-native-epoll</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-transport</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-common</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-codec</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-all</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
        <version>4.0.56.Final</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-websocket</artifactId>
        <version>3.3.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>3.3.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>3.3.2</version>
    </dependency>
    <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
            <version>3.3.2</version>
    </dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM