2

I am new in RESTful and WCF services and I'm making a RESTful with a JSON message format. When I run this service it gives no response.

This is my code:

[ServiceContract]
public interface IPersonas
{
    [OperationContract]
    [WebInvoke(Method="GET",BodyStyle=WebMessageBodyStyle.Bare,
    ResponseFormat=WebMessageFormat.Json,UriTemplate="getPeople")]
    Persona[] getPeople();
}

[DataContract]
public class Persona
{
    [DataMember(Name="nombre")]
    public string nombre { get; set; }

    [DataMember(Name="apellido")]
    public string apellido { get; set; } 

}

And my implementation:

 public Persona[] getPeople()
    {
        List<Persona> list = new List<Persona>()
        {

            new Persona(){nombre="luis",apellido="romeor"},
            new Persona(){nombre="alberto",apellido="calderton"},
            new Persona(){nombre="erick",apellido="romeor"},
            new Persona(){nombre="miguel",apellido="calderon"}

        };

        return list.ToArray();
    }

When I access Personas.svc/getPeople/ it gives no response. Sometimes the service opens on the service host test.

Peladao
  • 4,036
  • 1
  • 23
  • 43
BlaShadow
  • 11,075
  • 7
  • 39
  • 60

1 Answers1

2

Try doing this

  [ServiceContract]
  public interface IPersonas
  {
      [OperationContract]
      [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate="/getPeople")]
      Persona[] getPeople();
  }

Also use some code to test the URI, some browsers cache your request, may be thats why you don't get response always.

Amar Palsapure
  • 9,590
  • 1
  • 27
  • 46
  • the same response...I think could be the end points I've not set. – BlaShadow Jan 06 '12 at 07:48
  • Try this in web.config, – Amar Palsapure Jan 06 '12 at 07:54
  • the same response don't know what is the problems in many tutorial that I've saw they work without problem. – BlaShadow Jan 06 '12 at 08:02
  • Interesting, now i will go for the binding. In the "services" section have you defined like this . Please check the contract name, it should have a fully qualified name (with namespace). – Amar Palsapure Jan 06 '12 at 08:07
  • I got this response Sender a:DestinationUnreachable The message with To 'http://localhost:16669/Personas.svc/getPeople/' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree. – BlaShadow Jan 06 '12 at 08:13
  • Try this http://social.msdn.microsoft.com/forums/en-US/wcf/thread/b5ae495b-f5fb-4eed-ae21-2b2280d4fec3 – Amar Palsapure Jan 06 '12 at 08:17
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/6458/discussion-between-amar-palsapure-and-blashadow) – Amar Palsapure Jan 06 '12 at 08:21
  • If your problem is not solved, add this behavior – Amar Palsapure Jan 09 '12 at 12:31