There was no endpoint listening at that could accept the message This is often caused

I'm attempting to generate a WCF service for a Windows mobile smart device using a tutorial that I got. It suggested that I go the approach of using
netcfSvcUtil.exe intead of SvcUtil to generate the files that I would require. After writing the tutorial I was successful in publising my service but when I attempted to get my user to use it is gave me the below error:-
{"There was no endpoint listening at http://localhost:8000/calculator that could accept the msg. This is often caused by an incorrect address or SOAP action. See InnerException if present for more details."} System.Exception {System.ServiceModel.EndpointNotFoundException}
The code snippet for the service is
using System; using System.ServiceModel; using System.Collections.Generic; using System.Linq; using System.Text; namespace OpenNETCF.WCF.Sample { ServiceContract(Namespace = "http://opennetcf.wcf.sample") public interface ICalculator { OperationContract int Add(int a  int b); } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace OpenNETCF.WCF.Sample { public class CalculatorService : ICalculator { public int Add(int a  int b) { Console.WriteLine(string.Format( "Received 'Add({0}  {1})' returning {2}"  a  b  a + b)); return a + b; } } using System; using System.ServiceModel; using System.ServiceModel.Description; using System.Net; namespace OpenNETCF.WCF.Sample { public class Server { protected static Uri address; protected static ServiceHost serviceHost; static void Main(string args) { address = new Uri("http://localhost:8000/calculator"); serviceHost = new ServiceHost(typeof(CalculatorService)  address); serviceHost.AddServiceEndpoint(typeof(ICalculator)  new BasicHttpBinding()  address); ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; serviceHost.Description.Behaviors.Add(smb); serviceHost.Open(); Console.WriteLine( "CalculatorService is running at " + address.ToString()); Console.WriteLine("Press  to terminate"); Console.ReadLine(); // Close the ServiceHostBase to shutdown the service. serviceHost.Close(); } } }
The below is my user.
using System; using System.Linq; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.ServiceModel; using SMC = System.ServiceModel.Channels; using System.Runtime.Serialization; using System.Drawing; using System.Text; using System.Net; using System.Windows.Forms; namespace WCFClient { public partial class Form1 : Form { public Form1() { InitializeComponent(); try{ localIP.Text = Dns.GetHostEntry( Dns.GetHostName()).AddressList0.ToString(); } catch (Exception ex) { MessageBox.Show("No NIC got?"); } } private void textBox1_TextChanged(object sender  EventArgs e) { } private void button1_Click(object sender  EventArgs e) { MessageBox.Show("The button was clicked"); int a = 0; int b = 0; try { //a = int.Parse(localIP.Text); //b = int.Parse(serviceAddress.Text); a = int.Parse(1st.Text); b = int.Parse(second.Text); } catch { // parsing unsucessful  just bail out MessageBox.Show("parsing unsucessful  just bail out"); return; } SMC. Binding binding = CalculatorClient.CreateDefaultBinding(); string remoteAddress = CalculatorClient.EndpointAddress.Uri.ToString(); //remoteAddress = remoteAddress.Replace("localhost"  serviceAddress.Text); EndpointAddress endpoint = new EndpointAddress(remoteAddress); CalculatorClient user = new CalculatorClient(binding  endpoint); try { solution.Text = user.Add(a  b).ToString(); } catch (Exception ex) { MessageBox.Show(ex.msg); } } private void Form1_Load(object sender  EventArgs e) { } } }
Can anyone Plz tell me How can i fix this error...thanks

Get Source Code

  Views 212   Posted on : Sunday, April 07, 2013 10:38:32 AM
Related Tags:

Replies on "There was no endpoint listening at that could accept the message This is often caused" :

Nobody has replied on this post , be first to post answer.

Post Your Answer/Comment:

Please Login first to post Reply !

Note: Please Put Code into <code></code> block.

Also See: