0
votes

I have created a WCF service with some endpoints(with mex endpoint). If i create for example a Console Host now and put this in my main:

 ServiceHost host = new ServiceHost(typeof(HelloWorld));

 host.Open();

 Console.WriteLine("The service is ready at!");
 foreach (ServiceEndpoint se in host.Description.Endpoints)
          Console.WriteLine(se.Address.ToString());
      Console.WriteLine("Press <Enter> to stop the service.");
 Console.ReadLine();

// Close the ServiceHost.
host.Close();

Is it possible to generate a app.config on the hostside by adding a service reference, or do i need to create the app config my self and make it similar to the wcf service endpoints?

Next to this, how is it possible that some other computer on the LAN can access this host?

(PS what the heck does this mean: A service may inlcude an mex endpoint, which obtain the ABC's of the service and returns the WSDL. (NOW THE NOT UNDERSTANDABLE PART) After the WSDL is obtained, two artifacts are generated: a proxy class in the language of the project and an app.config file. The proxy class mirrors the signature of the endpoint operations so that client code can simply "call"an endpoint. The proxy interface doesn't have to be identical to the service signature, but the proxy needs to ensure that the message transmitted to the service is precisely what is described by the service contract.(OK WHAT?)

2

2 Answers

0
votes

1) You have to specify endpoints(A-Address,B-Binding,C-contract) in the app.config and this app.config must be with your host app(Your console app in this case) 2) This service can be recognized in the LAN if some client runs visual studio's command prompt and runs this-

SvcUtil http://localhost/MyService/MyService.svc /out:c:\Proxy.cs (sample command change various values as per your case...)

Here Proxy.cs contains Proxy class, the client should add this to the solution and calls the method of proxy class, in the same directory where this Proxy.cs exists, you will find 1 .config file, paste this file's contents to the client's app.config. 3) MEX endpoint is required to exchange meta information.

0
votes

In your first question I assume you mean "client" when you said "host". For this you should put a Uri in the constructor of the ServiceHost in your code. E.g.

ServiceHost host = new ServiceHost(typeof(HelloWorld), new Uri("http://localhost:1234/helloworld", UriKind.Absolute)); 

Then right click your project and go to Debug/Start new instance. Now your service is up and running under the given Uri. In Visual Studio go to the Debug menu at the top and choose "Detach all". Now your application with the service is still running. You can now go to your client project and add service reference like you're used to. Just fill in the Uri in the Add service reference dialog.

For your last question. It just means that visual studio creates a local file for your service reference and that as a developer you should use that client class as if it is the service itself and that it works :-)