sephora 0 Newbie Poster

I am trying to create a WCF service for a Windows mobile smart device using a tutorial that I found. It suggested that I go the way of using

netcfSvcUtil.exe intead of SvcUtil to generate the files that I would need. After writing the tutorial, I was successful in publising my service, but when I tried to get my client to use it it gave me the following error:-

{"There was no endpoint listening at http://localhost:8000/calculator that could accept the message. 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 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 = "")]

 

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 <ENTER> to terminate");

 

Console.ReadLine();

 

// Close the ServiceHostBase to shutdown the service.

serviceHost.Close();

}

}

}

The following is my client.

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()).AddressList[0].ToString();

}

 

catch (Exception ex)

{

 

MessageBox.Show("No NIC found?");

}

}

 

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(first.Text);

b =

int.Parse(second.Text);

}

 

catch

{

 

// parsing failed, just bail out

 

MessageBox.Show("parsing failed, 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 client = new CalculatorClient(binding, endpoint);

 

try

{

answer.Text = client.Add(a, b).ToString();

}

 

catch (Exception ex)

{

 

MessageBox.Show(ex.Message);

}  

 

}

 

private void Form1_Load(object sender, EventArgs e)

{

}

}

}

Can someone please tell me how to solve this error...thanks

Dani AI

Generated

— the exception you saw means the client could not reach a listening endpoint. Typical culprits are: the service process not actually running or listening on the expected address/port, the client using an address that is not reachable from the device/emulator (for example using the host machine's "localhost"), a firewall blocking the port, or a mismatch between the client proxy and the service (binding, contract namespace or SOAP action).

A practical checklist to isolate the problem:

  • Verify the service host is running and the metadata page (WSDL) is reachable from the machine you are testing from.
  • Confirm the OS is listening on the expected port (example command to run on the host machine):
    netstat -an | findstr 8000
  • If running on Windows Vista/7/Server, confirm any URL reservations or rights are correct:
    netsh http show urlacl
  • From the mobile emulator or device, do not assume "localhost" refers to the host PC. Use the host PC IP or machine name and ensure the emulator has network access (or bridge the emulator NIC). The client code you posted shows a commented attempt to replace "localhost" at runtime — that indicates this exact issue may be present.

Other focused checks:

  • Temporarily disable the host firewall or add an inbound rule for the service port to rule out blocking.
  • Regenerate the client proxy for the target service and verify the ServiceContract namespace and operation names match; a SOAPAction mismatch will cause the call to fail.
  • Enable WCF message logging / tracing on the service to capture incoming requests and SOAPAction values (this is the fastest way to see mismatches).

Microsoft documentation that explains the exception and WCF troubleshooting techniques may help: EndpointNotFoundException - Microsoft Docs and .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.