使用 Java 访问 WCF 服务
我正在使用 WCF 开发一个 Web 服务,我想使用用 Java 编写的客户端来访问它。我将使用 Protocol Buffers 对消息进行编码(Marc Gravell 的 protobuf-net 为精确的)。
这是否可以实现,或者客户端也必须用 .NET 编写?我知道使用 Protocol Buffers 序列化的数据是二进制互操作的,但我不知道 WCF 是否在编码的协议消息之上添加任何特定于平台的元数据。
我不关心 WCF 服务是否是 RESTful、基于 SOAP 或任何其他形式的 WCF 支持,我只希望使用 PB 对实际有效负载进行编码。这是否可能,如果可能,我将非常感谢一个简短的例子。
I'm developing a web-service using WCF, which I want to access using a client written in Java. I will encode the messages using Protocol Buffers (with Marc Gravell's protobuf-net to be exact).
Is this possible to achive or must the client be written in .NET as well? I know that data serialized with Protocol Buffers is binary interopable but I don't know if WCF adds any platform-specific meta-data on top of the encoded protocol-messages.
I don't care if the WCF-service is RESTful, SOAP-based or whatever other forms WCF-support, I just want the actual payload to be encoded using PB. Is this possible and if it is, I would very much appreciate a brief example.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您对 WCF 服务进行编程以获取字节数组,则可以在其中填充您想要的任何内容,例如 protobuf 消息。可以像
将 WCF 端点配置为 SOAP 一样简单,然后从
Java 应该是直接的。 WCF/Soap 对此是否会大材小用是另一回事,iirc protobuf 带有自己的简单 RPC 框架。
If you program your WCF service to take a byte array, you can stuff whatever you want in there, like a protobuf message.Could be as simple as
Configure the WCF endpoint as SOAP, then talking to that from
Java should be straight forward. Whether WCF/Soap would be overkill for this is another matter, iirc protobuf comes with its own framework for simple RPC.
我从未使用过 protobuf-net,但互操作才是重点。
I have never used protobuf-net but interop was the whole point.