Introduction:
This blog is all about how to upload file using WCF Services and use it in any client application.
Uploading a File to the server
For this purpose, I am creating a WCF Service. In the ServiceContract attribue, I am taking a Upload method which accepts the Instance of PictureFile class.
Step 1:
- Open Visual Studio and go to File menu.
- Select Visual Basic and WCF Service Application.
- Give the name as you desire and press OK.
- The IService.vb code is:
Code:
' NOTE:
You can use the "Rename" command on the "Refactor" menu to change the interface
name "IService1" in both code and config file together.
<ServiceContract()>
_
Public
Interface
IPictureService
<OperationContract()> _
Function Upload(picture
As PictureFile)
As
Boolean
' TODO: Add your service
operations here
End
Interface
<DataContract()>
_
Public
Class
PictureFile
<DataMember()>
_
Public Property
PictureName() As
String
Get
Return
m_PictureName
End
Get
Set(value
As String)
m_PictureName = Value
End
Set
End
Property
Private
m_PictureName As
String
<DataMember()> _
Public Property
PictureStream() As
Byte()
Get
Return
m_PictureStream
End
Get
Set(value
As Byte())
m_PictureStream = Value
End
Set
End
Property
Private
m_PictureStream As
Byte()
End
Class
Join the conversation! Your thoughts help the community grow.