Javi

webservice

Dec 5th, 2013
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. Imports System.ServiceModel
  2.  
  3. ' NOTE: You can use the "Rename" command on the context menu to change the interface name "IService1" in both code and config file together.
  4. <ServiceContract()>
  5. Public Interface IService1
  6.  
  7. <OperationContract()>
  8. <WebGet(UriTemplate:="estudiantes", ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Bare)>
  9. Function ObtenerEstudiantes() As List(Of Estudiante)
  10.  
  11. End Interface
  12.  
  13. Imports System.ServiceModel.Activation
  14.  
  15. ' NOTE: You can use the "Rename" command on the context menu to change the class name "Service1" in code, svc and config file together.
  16. ' NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.vb at the Solution Explorer and start debugging.
  17. <AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>
  18. Public Class Service1
  19. Implements IService1
  20.  
  21. Public Function ObtenerEstudiantes() As List(Of Estudiante) Implements IService1.ObtenerEstudiantes
  22.  
  23. Dim resultado As New List(Of Estudiante)
  24.  
  25. Dim e1 As New Estudiante()
  26. e1.Codigo = "1111"
  27. e1.Nombre = "Alice"
  28. resultado.Add(e1)
  29.  
  30. Dim e2 As New Estudiante()
  31. e2.Codigo = "2222"
  32. e2.Nombre = "Bob"
  33. resultado.Add(e2)
  34.  
  35.  
  36. Return resultado
  37.  
  38. End Function
  39.  
  40. End Class
  41.  
  42. Public Class Estudiante
  43.  
  44. Public Property Codigo As String
  45. Public Property Nombre As String
  46.  
  47. End Class
  48.  
  49.  
  50. Public Class Estudiante
  51.  
  52. Public Property Codigo As String
  53. Public Property Nombre As String
  54.  
  55. End Class
Advertisement
Add Comment
Please, Sign In to add comment