Ive been experimenting with WCF and added a DataContract to my server and updated a ServiceContract. When the ServiceReference was first added to the client, i was running them both on the same pc, so i used localhost. Ive now tried to connect 2 pc's via an ethernet cable and update the service reference that way. Ive set the servers ip address on the lan to 192.168.10.10
. The following code is executed when a button is clicked on the servers form.
private void btnCommenceService_Click(object sender, EventArgs e)
{
host = new ServiceHost((typeof(Service)), new Uri[] { new Uri("http://localhost:9000")});
host.AddServiceEndpoint(typeof(IServices),
new WSDualHttpBinding(),
"ServerService");
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
host.Description.Behaviors.Add(smb);
host.Open();
txtStatus.Text = "Service is open.";
}
Ive turned the firewall off on both pc's and have sucessfully ping'd the address "http://192.168.10.10"
from the client pc. Ive managed to access some random webpage as well if i type that into my browser.
In the client, if i click on my solution and select "Add Service Reference" and type in
"http://192.168.10.10"
"http://192.168.10.10:9000"
"http://192.168.10.10:9000/ServerService"
All of them come back with some form of error, usually something along the following lines:
The document at the url http://192.168.10.10:9000/ was not recognised as a known document type.
The error message for each known type may help u fix the problem:
-Report from 'XML Schema' is The document format is not recognised(the content type is 'text/html;charset=utf-8').'.
Report from DISCO Document is There was an error downloading `'http://localhost:9000/?disco'.'.`
Unable to connect to the remote server.
No connection could be made because the target machine actively refused it 127.0.0.1:9000
etc
Anyone got some pointers as to why its not working over the LAN yet i can access and ping the address?