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.
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
[ServiceContract]
public interface IMessageService{
[OperationContract(IsOneWay = true)]
void SendMessage(byte[] msg);
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class MessageService: IMessageService{
public void SendMessage(byte[] msg) {
//decode the protobuf msg and deal with it.
}
}
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.