I've been working really hard on a WCF Json-Rpc Service Model. I'm fairly new to WCF and WCF extensibility but finally I'm now able to process requests from a web browser :) To summarize it, I've now implemented an Endpoint Behavior, an Operation Selector, and a Message Formatter.
You can find the latest source code on this post on MSDN forum.
I'm now trying to create a WCF Client for it but I'm stuck with the following error:
Manual addressing is enabled on this factory, so all messages sent must be pre-addressed.
This is how I'm creating my client:
private int communicationTimeout = 10;
private int communicationPort = 80;
private string jsonRpcRoot = "/json.rpc";
public void InitializeClient()
{
Uri baseAddress = new UriBuilder(Uri.UriSchemeHttp, Environment.MachineName, communicationPort, jsonRpcRoot).Uri;
EndpointAddress address = new EndpointAddress(baseAddress.AbsoluteUri);
ChannelFactory<IJsonService> channelFactory = new ChannelFactory<IJsonService>(new WebHttpBinding(), address);
channelFactory.Endpoint.Behaviors.Add(new JsonRpcEndpointBehavior());
IJsonService typedProxy = channelFactory.CreateChannel();
int a = typedProxy.StartTransport(10);
}
And this is my (test) service contract. I kept it as simple as possible
[ServiceContract(Namespace = "")]
public interface IJsonService
{
[OperationContract]
IList<Mission> GetMissions();
[OperationContract]
int StartTransport(int missionId);
[OperationContract]
int TransportCompleted(int missionId);
}