While making WCF services sometimes you have scenarios that it needs to be done in VB
For doing that we will made the Service Contract after that we will made Operation Contract for defining method signature
<ServiceContract()>
Public Interface IService1
<OperationContract()>
<WebGet(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="GetCompanies")>
Function GetCompanies() As CompanyResponse
<OperationContract()>
<WebGet(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="GetJobRoles")>
Function GetJobRoles() As JobRoleResponse
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="RegisterUser")>
Function RegisterUser(ByVal user As User) As UserResponse
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="AuthenticateUser")>
Function AuthenticateUser(ByVal user As User) As UserResponse
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="LogOutUser")>
Function LogOutUser(ByVal user As User) As UserResponse
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="ForgotPassword")>
Function ForgotPassword(user As User) As UserResponse
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="GetNudgeLocations")>
Function GetNudgeLocations(ByVal location As Location) As LocationResponse
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="GetFriendsToNudge")>
Function GetFriendsToNudge(ByVal user As User) As UsersResponse
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="SaveNudgeForFriend")>
Function SaveNudgeForFriend(ByVal nudge As Nudge) As NudgeResponse
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="DeleteNudge")>
Function DeleteNudge(ByVal nudge As Nudge) As NudgeResponse
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="GetNudges")>
Function GetNudges(ByVal nudge As Nudge) As NudgesResponse
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="GetUserProfile")>
Function GetUserProfile(ByVal user As User) As UserResponse
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="UpdateUserProfile")>
Function UpdateUserProfile(ByVal user As User) As UserResponse
End Interface
And we will made the Data Models associated with it will also made that is used by these operations or methods
#Region "=== Company Model ==="
<DataContract()>
Public Class Company
<DataMember()>
Public Property Id As String
<DataMember()>
Public Property Company As String
End Class
<DataContract()>
Public Class Companies
Public Sub New()
Me.Companies = New List(Of Company)
End Sub
<DataMember()>
Public Property Companies As List(Of Company)
End Class
<DataContract()>
Public Class CompanyResponse
<DataMember()>
Public Property Data As Companies
<DataMember()>
Public Property Status As Boolean
<DataMember()>
Public Property Message As String
End Class
#End Region
#Region "=== Job Model ==="
<DataContract()>
Public Class JobRole
<DataMember()>
Public Property Id As String
<DataMember()>
Public Property JobRole As String
End Class
<DataContract()>
Public Class JobRoles
Public Sub New()
Me.JobRoles = New List(Of JobRole)
End Sub
<DataMember()>
Public Property JobRoles As List(Of JobRole)
End Class
<DataContract()>
Public Class JobRoleResponse
<DataMember()>
Public Property Data As JobRoles
<DataMember()>
Public Property Status As Boolean
<DataMember()>
Public Property Message As String
End Class
0 Comment(s)