Hi
My web service has a method which accepts byte array as parameter.
<WebMethod()> _
Public Function SendLoan(ByVal data As Byte()) As String
Dim filePath As String
filePath = System.AppDomain.CurrentDomain.BaseDirectory() &
"\WorkingFiles\"
objImportExport = New BrainImportExport.BrainImportExport
SendLoan = objImportExport.ImportLoanByLoan(data, filePath)
objImportExport = Nothing
End Function
I am calling this function from VBA client. Following is the code
Dim arr1() As Byte
ReDim arr1(Len("Data=" & xmlDoc.xml))
arr1 = StrConv(("Data=" & xmlDoc.xml), vbFromUnicode)
Dim objXMLHTTP As New MSXML2.XMLHTTP30
Dim strResponse As String
Dim strURL As String 'Web service url
strURL = "http://localhost/brainwebservices/brainwebservices.asmx/SendLoan"
objXMLHTTP.Open "POST", strURL, True
objXMLHTTP.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
objXMLHTTP.setRequestHeader "Content-Length", UBound(arr1)
'Call web service and pass its parameters
objXMLHTTP.send arr1
'>>> Loop until the call comes back
Do Until objXMLHTTP.readyState = 4
DoEvents
Loop
'When exiting the loop, get the response from the webservice
strResponse = objXMLHTTP.responseText
If objXMLHTTP.statusText = "OK" Then
MsgBox "Data sent to web services successfully"
Else
MsgBox "Error in sending data to web services"
End If
I am getting following error:
System.ArgumentException: Cannot convert to System.Byte.
Parameter name: type ---> System.FormatException: Input string was not
in a correct format.
at System.Number.ParseInt32(String s, NumberStyles style,
NumberFormatInfo info)
at System.Byte.Parse(String s, NumberStyles style, IFormatProvider
provider)
at System.String.System.IConvertible.ToByte(IFormatPr ovider
provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at System.Web.Services.Protocols.ScalarFormatter.From String(String
value, Type type)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.ScalarFormatter.From String(String
value, Type type)
at System.Web.Services.Protocols.ValueCollectionParam eterReader.Read(NameValueCollection
collection)
at System.Web.Services.Protocols.HtmlFormParameterRea der.Read(HttpRequest
request)
at System.Web.Services.Protocols.HttpServerProtocol.R eadParameters()
at System.Web.Services.Protocols.WebServiceHandler.In voke()
at System.Web.Services.Protocols.WebServiceHandler.Co reProcessRequest()
Earlier i was using SOAP Toolkit 3.0.It was working fine.
Please let me know if am missing anything.
Thanks in advance
Regards
gagan