473,785 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.AppDomai n.CurrentDomain .BaseDirectory( ) &
"\WorkingFiles\ "
objImportExport = New BrainImportExpo rt.BrainImportE xport
SendLoan = objImportExport .ImportLoanByLo an(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.XMLHTTP3 0
Dim strResponse As String
Dim strURL As String 'Web service url
strURL = "http://localhost/brainwebservice s/brainwebservice s.asmx/SendLoan"
objXMLHTTP.Open "POST", strURL, True
objXMLHTTP.setR equestHeader "Content-Type",
"applicatio n/x-www-form-urlencoded"
objXMLHTTP.setR equestHeader "Content-Length", UBound(arr1)
'Call web service and pass its parameters
objXMLHTTP.send arr1
'>>> Loop until the call comes back
Do Until objXMLHTTP.read yState = 4
DoEvents
Loop
'When exiting the loop, get the response from the webservice
strResponse = objXMLHTTP.resp onseText
If objXMLHTTP.stat usText = "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.Argument Exception: Cannot convert to System.Byte.
Parameter name: type ---> System.FormatEx ception: Input string was not
in a correct format.
at System.Number.P arseInt32(Strin g s, NumberStyles style,
NumberFormatInf o info)
at System.Byte.Par se(String s, NumberStyles style, IFormatProvider
provider)
at System.String.S ystem.IConverti ble.ToByte(IFor matProvider
provider)
at System.Convert. ChangeType(Obje ct value, Type conversionType,
IFormatProvider provider)
at System.Convert. ChangeType(Obje ct value, Type conversionType)
at System.Web.Serv ices.Protocols. ScalarFormatter .FromString(Str ing
value, Type type)
--- End of inner exception stack trace ---
at System.Web.Serv ices.Protocols. ScalarFormatter .FromString(Str ing
value, Type type)
at System.Web.Serv ices.Protocols. ValueCollection ParameterReader .Read(NameValue Collection
collection)
at System.Web.Serv ices.Protocols. HtmlFormParamet erReader.Read(H ttpRequest
request)
at System.Web.Serv ices.Protocols. HttpServerProto col.ReadParamet ers()
at System.Web.Serv ices.Protocols. WebServiceHandl er.Invoke()
at System.Web.Serv ices.Protocols. WebServiceHandl er.CoreProcessR equest()
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 4422

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

Similar topics

2
15678
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 HTTP GET method. The problem is, how to assign stream from downloaded image (ex. GIF89a) to a JavaScript Image object ? Below is my code with explanation what I'm trying to do:
3
3160
by: Paul Michaud | last post by:
Consider the following: Class A { .... } Class B:A { ....
22
25607
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 compile. <WebMethod()> _ Public Function VerifySku(ByVal skus As XmlDataDocument) As DataSet Test program : Dim cartSet As DataSet cartSet = ws.VerifySku(cartSet)
0
443
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 = System.AppDomain.CurrentDomain.BaseDirectory() & "\WorkingFiles\" objImportExport = New BrainImportExport.BrainImportExport SendLoan = objImportExport.ImportLoanByLoan(data, filePath) objImportExport = Nothing
0
1192
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 the binary data of the html page I am reading
0
1001
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 the binary data of the html page I am reading
2
2114
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 the binary data of the html page I am reading
1
14456
by: Andy | last post by:
Hi, I created a sample web service and tried calling it from my VBScript. Here it is: ---------------------------------------------------------------------------- --------------- '-- Declare variables dim fs
2
2384
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 BinaryStream.Read(BinaryStream.Size) Is this the correct approach?
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10341
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7502
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.