So my previous question revolved around turning wcf into a restful service convert a WCF Service, to a RESTful application?, which I managed to do with some help!
But I am running into a new problem from my client:
There was no endpoint listening at http://localhost:26535/Service1.svc that could accept the message.
This is often caused by an incorrect address or SOAP action. See
InnerException, if present, for more details.
Now the restful service runs as can be seen from a screen dump:

And I can add from the url the value 1 like so:

But yet I cant seem to run it on another new instance of visual studio, my client app.config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="WebHttpBinding_IService1">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport></httpTransport>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:26535/Service1.svc" binding="customBinding" bindingConfiguration="WebHttpBinding_IService1"
contract="ServiceReference1.IService1" name="WebHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
Client code:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public ServiceReference1.Service1Client testClient = new ServiceReference1.Service1Client();
private void button1_Click(object sender, EventArgs e)
{
label1.Text = testClient.GetData(Convert.ToInt32(textBox1.Text));
}
}
}
I was looking at previous problems in this area on SO here: WCF – "There was no endpoint listening at…" error
But it provides no solution? Im not familiar with hosting on IIS or what not this is just practice so having it work on debug (F5) would be zer goood!
This might actually be due to the change to the REST service.
Try removing/commenting out this from your host config
It seems that REST does not pass over any metadata (thus the removal of the mex)
If you then reset your service reference, it should work properly…I believe.
Also, this article might prove useful
If you are able to use a third party, then I would suggest using RestSharp. It makes consuming RESTful services extremely easy 🙂
Or you could use the newer WebAPI that can make these calls more direct also? The problem is that RESTful services are not as easily consumed the way SOAP calls are/were