サーバー側
''' <summary>
''' クライアントへファイルを送出する
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
<WebMethod()> _
Public Function GetFile() As Byte()
Dim filePath As String = "E:\Webサービステスト\GetFile\testdb.odb"
Using fs As New System.IO.FileStream(filePath, IO.FileMode.Open)
Dim ret(fs.Length) As Byte
fs.Read(ret, 0, ret.Length)
Return ret
End Using
End Function
''' <summary>
''' クライアントからファイルを受け取る
''' </summary>
''' <param name="file"></param>
''' <remarks></remarks>
<WebMethod()> _
Public Sub PutFile(ByVal file As Byte())
Dim filePath As String = "E:\Webサービステスト\PutFile\testdb.odb"
Using fs As New System.IO.FileStream(filePath, IO.FileMode.Create)
fs.Write(file, 0, file.Length)
End Using
End Sub
''' クライアントへファイルを送出する
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
<WebMethod()> _
Public Function GetFile() As Byte()
Dim filePath As String = "E:\Webサービステスト\GetFile\testdb.odb"
Using fs As New System.IO.FileStream(filePath, IO.FileMode.Open)
Dim ret(fs.Length) As Byte
fs.Read(ret, 0, ret.Length)
Return ret
End Using
End Function
''' <summary>
''' クライアントからファイルを受け取る
''' </summary>
''' <param name="file"></param>
''' <remarks></remarks>
<WebMethod()> _
Public Sub PutFile(ByVal file As Byte())
Dim filePath As String = "E:\Webサービステスト\PutFile\testdb.odb"
Using fs As New System.IO.FileStream(filePath, IO.FileMode.Create)
fs.Write(file, 0, file.Length)
End Using
End Sub
クライアント側
Public Class Form1
Private Const WebServiceUrl As String = "http://IPアドレス/WebService/Service.asmx"
Private Sub cmdGetFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles cmdGetFile.Click
Dim filePath As String = "ファイルパス"
Dim CallWebService As New WebReference.Service
CallWebService.Url = WebServiceUrl
Dim file() As Byte
file = CallWebService.GetFile()
Using fs As New System.IO.FileStream(filePath, IO.FileMode.Create)
fs.Write(file, 0, file.Length)
End Using
End Sub
Private Sub cmdPutFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles cmdPutFile.Click
Dim filePath As String = "ファイルパス"
Dim CallWebService As New WebReference.Service
CallWebService.Url = WebServiceUrl
Using fs As New System.IO.FileStream(filePath, IO.FileMode.Open)
Dim file(CInt(fs.Length)) As Byte
fs.Read(file, 0, file.Length)
Call CallWebService.PutFile(file)
End Using
End Sub
End Class
Private Const WebServiceUrl As String = "http://IPアドレス/WebService/Service.asmx"
Private Sub cmdGetFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles cmdGetFile.Click
Dim filePath As String = "ファイルパス"
Dim CallWebService As New WebReference.Service
CallWebService.Url = WebServiceUrl
Dim file() As Byte
file = CallWebService.GetFile()
Using fs As New System.IO.FileStream(filePath, IO.FileMode.Create)
fs.Write(file, 0, file.Length)
End Using
End Sub
Private Sub cmdPutFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles cmdPutFile.Click
Dim filePath As String = "ファイルパス"
Dim CallWebService As New WebReference.Service
CallWebService.Url = WebServiceUrl
Using fs As New System.IO.FileStream(filePath, IO.FileMode.Open)
Dim file(CInt(fs.Length)) As Byte
fs.Read(file, 0, file.Length)
Call CallWebService.PutFile(file)
End Using
End Sub
End Class
0 件のコメント:
コメントを投稿