Is it possible to communicate with a WCF service without using NETCFSvcUtil to generate the proxy?
I'm trying to call a WCF service on a mobile using compact framework. I do not want to use NETCFSvcUtil to generate a proxy for a particular reason.
I have this sample code on the mobile side to test it out :
// This is the contract defined at the client side (mobile device)
public interface IService1
{
string GetData(int value);
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
string address = "http://192.168.30.88:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/";
// It throws here ....
var channelFactory = CreateDefaultBinding().BuildChannelFactory<IService1>(new System.ServiceModel.Channels.BindingParameterCollection());
var channel = channelFactory.CreateChannel(new EndpointAddress(new Uri(address)));
var result = channel.GetData(5);
this.Text = result.ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
public static System.ServiceModel.Channels.Binding CreateDefaultBinding()
{
System.ServiceModel.Channels.CustomBinding binding = new System.ServiceModel.Channels.CustomBinding();
binding.Elements.Add(new System.ServiceModel.Channels.TextMessageEncodingBindingElement(System.ServiceModel.Channels.MessageVersion.Soap11, System.Text.Encoding.UTF8));
binding.Elements.Add(new System.ServiceModel.Channels.HttpTransportBindingElement());
return binding;
}
}
But I'm getting this exception : Channel type 'CallingWCFFromDevice.IService1' was requested, but Binding 'CustomBinding' doesn't support it or isn't configured properly to support it. Parameter name: TChannel
Any clue to what is going on? I'm guessing i'm not using the BuildChannelFactory correctly ...