开发者

VB6 base64 Binary

I have a problem on this webservice:

http://credenciados.pronto.com.br/carga.asmx?op=IncluirMultimidia2

on arrayArquivo parameter, i use this function to generate data:

Private Function getBase64fromFile(Filename) As String

   Dim base64 As New cls64base

   Dim FileInputDat开发者_如何学Ca() As Byte

   Open Filename For Binary As #1
   FileInputData = String(LOF(1), 0)
   Get #1, 1, FileInputData
   Close #1

   getBase64fromFile = base64.Base64Encode(FileInputData)

End Function

When i Call the service i receive this error:

Type conversion failure for element arrayArquivo

Obs:

Im using:

  • Microsoft Soap ToolKit 3.0
  • Visual Basic 6


I'm not sure what this problem is, but I use the following pair of routines to get binary data from a file, then base64 encode it. Code requires the MSXML library - I use version 3, which should be available to all Win2K+ versions.

For getting the binary data from a file:

Public Function GetFileData(ByVal Filename As String) As Byte()

    Dim f As Integer

    f = FreeFile

    Open Filename For Binary Access Read As #f
    ReDim GetFileData(0 To LOF(f) - 1)
    Get #f, , GetFileData
    Close #f

End Function

For converting the byte array into a base64 string:

Public Function GetBase64String(ByRef data() As Byte) As String

    Dim doc As DOMDocument
    Dim root As IXMLDOMElement

    Set doc = New DOMDocument
    Set root = doc.createElement("encode")
    root.dataType = "bin.base64"
    root.nodeTypedValue = data

    GetBase64String = root.Text

Exit Function
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜