Hi guys I just want a simple WinForm app with one button. When I press the button i want to start the selfhosted WCF service. I want to able to connect to this service with for example another client app (winforms) by just adding a service reference.
However the solution that I created is not working. I can't get connected with adding a service reference to this service. I don't actually know what address to call than except the address that I defined in the app.config file. Any help would be great.
Here is the app.config file.
<configuration>
<system.serviceModel>
<services>
<service name="WindowsFormsApplication11.WmsStatService">
<endpoint address="http://192.168.0.197:87" binding="basicHttpBinding"
bindingConfiguration="" contract="WindowsFormsApplication11.IWmsStat"/>
</service>
</services>
</system.serviceModel>
</configuration>
And forms code:
namespace WindowsFormsApplication11
{
public partial class Form1 : Form
{
public ServiceHost _host = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
_host = new ServiceHost(typeof(WmsStatService));
_host.Open();
}
}
// Define a service contract.
[ServiceContract(Namespace = "http://WindowsFormsApplication11")]
public interface IWmsStat
{
[OperationContract]
string sayHello(string name);
}
public class WmsStatService : IWmsStat
{
public string sayHello(string name)
{
return "hello there " + name + " nice to meet you!";
}
}
}