Im creare un semplice servizio Web in un'app console. (PersonService) questo è il mio Program.cs sottoaggiungere un riferimento al servizio Web a un'app console
sto cercando di aggiungere un riferimento di servizio a un'altra app di console (PersonClient) come posso fare questo? ho provato ad aggiungerlo facendo clic con il pulsante destro del mouse, aggiungendo riferimento al servizio, indicando il refernce ecc ... ma non funzionerà.
[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();
}
}
}
grazie che ha aiutato – raklos
Contento di aver potuto aiutare. – RichardOD