Java Socket Server——重定向到Web应用程序(Web服务)
我有以下要求:
我需要创建一个侦听传入请求的套接字服务器。套接字客户端是用 C 编写的。客户端发送 JSON 数据。
客户端输入需要重定向到不同的源。例如,可能需要调用内部或外部 Web 服务(SOAP、JAX-WS)。
我的问题是,实现这种沟通的最佳方式是什么?
I have the following requirement:
I need to create a socket server that listens fro incoming requests. The socket clients are written in C. The clients send JSON data.
The client input needs to be redirected to different sources. for example there might be a need to call an internal or external web service(SOAP, JAX-WS).
My question is, what is the best way to achieve such a communication?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将作为观察者实现重定向服务,并在调用您的可观察对象(侦听的套接字服务器)时通知他。如果您不熟悉该模式,请查看 http://en.wikipedia.org/wiki /观察者模式。基本上,您通过将信息进一步推向流程链来保持信息流,而不是通过重定向服务主动拉动信息。
我希望您不需要任何有关 SOAP、JAX-WS 内容的帮助 - 与您通常实现此类服务的方式相比,您的要求不会改变任何内容。 (如果您像我一样懒,请使用 wsimport 命令行应用程序 ^^)
I would implement the redirecting service as an observer and notify him when your observable (the socket server that listens) is called. If you're not familiar with that pattern, have a look at http://en.wikipedia.org/wiki/Observer_pattern. You basically keep up the information flow by pushing your information further down the chain of processes instead of pulling it actively by your redirecting service.
I hope you didn't need any help with the SOAP, JAX-WS stuff - your requirement doesn't change anything compared to the way you would normally implement such a service. (If you're as lazy as me, go with the wsimport commandline application ^^)