Im creating a simple web service in a console app. (PersonService) this is my Program.cs below
im trying to add a service reference to a different console app (PersonClient) how can i do this? i tried adding it by right clicking, add service reference, pointing to the refernce etc... but it wont work.
[DataContract]
public class Person
{
[DataMember]
public string FirstName { get; set; }
[DataMember]
public string LastName { get; set; }
}
[ServiceContract]
public interface IPersonLookup
{
[OperationContract]
Person GetPerson(int identifier);
}
public class PersonService : IPersonLookup
{
public PersonService()
{
}
public Person GetPerson(int identifier)
{
Person p = new Person();
p.FirstName="Jane";
p.LastName="Doe";
return p;
}
}
class Program
{
static void Main(string[] args)
{
using (ServiceHost host = new ServiceHost(typeof(PersonService)))
{
WSHttpBinding binding = new WSHttpBinding();
host.AddServiceEndpoint(typeof(IPersonLookup), binding, "http://localhost:9090/PersonService");
host.Open();
Console.WriteLine("Listening....");
Console.ReadLine();
}
}
}
To add a Web Reference You can also open the Add Web Reference dialog box in the Solution Explorer pane by right-clicking References and selecting Add Web Reference. In the Web reference name box, rename the Web reference toExcelWebService. Click Add Reference to add a Web reference for the target Web service.
as web. config, but for console and WinForms applications. To add one to your project, right-click the project in Solution Explorer, Add..., New Item... and pick "Application Configuration File" from the Templates box.
To add a reference to a service in the current solution (. NET Framework projects) In Solution Explorer, right-click the name of the project to which you want to add the service, and then click Add Service Reference. The Add Service Reference dialog box appears.
Solution:
You need to read about WCF MEX Endpoints. Here's a blog post that may help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With