473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Passing binary data to a web service method using XMLHttp from VBA code

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
Jul 21 '05 #1
0 4398

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sergiusz Michalski | last post by:
Hallo!! According to my previous post with popups hanging, now I'm trying to bypass this strange behaviour using loading JavaScript image not by image.src=URL but straight away from stream using...
3
by: Paul Michaud | last post by:
Consider the following: Class A { .... } Class B:A { ....
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
0
by: gagans | last post by:
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 =...
0
by: Slim | last post by:
I have a problem converting binary to text I am reading a page using xmlhttp xmlhttp.open "GET", url, false ,"userName","password" xmlhttp.send "" tex3 = xmlhttp.responseBody now I have...
0
by: Slim | last post by:
I have a problem converting binary to text I am reading a page using xmlhttp xmlhttp.open "GET", url, false ,"userName","password" xmlhttp.send "" tex3 = xmlhttp.responseBody now I have...
2
by: Slim | last post by:
I have a problem converting binary to text I am reading a page using xmlhttp xmlhttp.open "GET", url, false ,"userName","password" xmlhttp.send "" tex3 = xmlhttp.responseBody now I have...
1
by: Andy | last post by:
Hi, I created a sample web service and tried calling it from my VBScript. Here it is: ---------------------------------------------------------------------------- --------------- '-- Declare...
2
by: Andy | last post by:
Hi there, How do I send binary files to a web service from VBScript? I read a file, converted it into a stream and submitted using xmlhttp.send (post method). objXmlhttp.send...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.