Thursday, August 4, 2011

Step 1:
Start--> Programs-- >Microsoft Visual Studio 2008-- > Microsoft Visual Studio 2008.
Step 2:
File-- >New Project-- >Web-- >WCF Service Application-- >Name the Solution (e.g. MyFirstWCFApplication) and Save.

It will generate following Files structures.

Step 3:
Click on Default file named (IService1.vb). It creates default

' NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.

Public Interface IService1

Function GetData(ByVal value As Integer) As String

Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType

' TODO: Add your service operations here
End Interface
' Use a data contract as illustrated in the sample below to add composite types to service operations.
Public Class CompositeType

Private boolValueField As Boolean
Private stringValueField As String

Public Property BoolValue() As Boolean
Return Me.boolValueField
End Get
Set(ByVal value As Boolean)
Me.boolValueField = value
End Set
End Property

Public Property StringValue() As String
Return Me.stringValueField
End Get
Set(ByVal value As String)
Me.stringValueField = value
End Set
End Property
End Class

1. In _ there is one Interface named IService1. This may be changed.
2. Each _ having Interface may have multiple Funtions preceded with _.
3. Add the Functions like to invoke or Expose.
3. All defined or renamed Interfaces references must be updated in Web.config file.

4. In _ there is one CompositeType class. Inside _ there are many _ which is nothing but the Property of the class used to expose to the outer world. Each Property must precedded with _ else it will not be exposed.

Step 4:
Now Click on Service1.svc.vb a class file that Implement s the defined Contracts. Define the function defined by Interface and save this file.
Step 5:
Build the application.
After Building the application this Application can be used by Client Applications in different ways.
1. By Adding Service reference Locally
2. By Hosting it on IIS

No comments:

Post a Comment