Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    [c#] Implementare WCF service Restful

    Ciao a tutti,

    ho implementato un servizio WCF restful ma non appare niente richiamando la pagina: posto il codice.

    codice:
    public class RestJSONService : IRestJSONService
        {
    
            #region IRestJSONService Members
    
            public Person[] GetPeople()
            {
                return PeopleRepository.People.ToArray();
            }
    
            public  Person[] SavePerson(string name, string firstname, string age)
            {
                Person p = new Person { FirstName = firstname, LastName = firstname, age = Convert.ToInt32(age) };
              PeopleRepository.People.Add(p);
                 return PeopleRepository.People.ToArray();
    
            }
    
            #endregion
    
            public static class  PeopleRepository
            {
               public static List<Person> People = new List<Person>(){
                new Person { FirstName = "Luca", LastName = "Rossi", age = 20 },
                new Person { FirstName = "Mario", LastName = "Bianchi", age = 33 },
                new Person { FirstName = "Gigi", LastName = "Verdi", age = 50 },
                new Person { FirstName = "Maria", LastName = "Gialli", age = 26 }};
    
            }

    interfaccia
    codice:
     [ServiceContract]
        public interface IRestJSONService
        {
            [OperationContract]
            [WebInvoke(Method="GET", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat=WebMessageFormat.Xml,UriTemplate="GetPeople")]
            Person[]GetPeople();
    
            [OperationContract]
            [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "SavePerson?name={name}&firstname={firstname}&age={age}")]
            Person[] SavePerson(string name, string firstname,string age);
        }
    
        [DataContract(Name = "Person")]
        public class Person
        {
            [DataMember(Name = "FirstName")]
            public string FirstName { get; set; }
            [DataMember(Name = "LastName")]
            public string LastName { get; set; }
            [DataMember(Name = "age")]
            public Int32 age { get; set; }
    
        }
    Francamente non riesco a capire dove sbaglio, se provo a richiamare l'url http://localhost:4637/RestJSONService.svc/GetPeople non si vede niente...qualche idea?

    Grazie

    Mike "The Ram"

  2. #2
    Hai provato ad usare WCFTestClient.exe e verificare quale sia l' errore?

  3. #3
    Ciao,

    ho a disposizione un visual web developer 2008, è un plugin compatibile con questo ambiente?

  4. #4
    Nella cartella di installazione del framework trovi un eseguibile che si chiama WCFTestClient.exe che ti consente di testare i tuoi servizi WCF.

  5. #5
    Risolto con un client per Firefox, provero' poi ad eseguire quello che mi hai appena scritto

    Thank you!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.