473,322 Members | 1,504 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,322 software developers and data experts.

How to get the return value(array type) of a webservice method in ASP

I'm a novice on ASP using VBScript, and I encountered a problem when I
want to get and use a return value of a web method in my ASP code.

There is a web method called "getQuote", which takes a string
indicating the symbols as its parameter, and return an array of
"BTQuote" objects which contain the info of every symbol respectively.

Also, there is a proxy object which is generated automatically by the
IDE. This proxy object is wrapped as a COM tlb and deployed on the
server, correctly, i'm sure.

I want to write ASP code to get the returned "BTQuote" array so that I
can show the information, can anybody tell me how to do that ?

ps, I've already written the following code to initiate a service
object, it worked fine:
Set btService = Server.CreateObject("BTLib.BTDemoService")
////////How do I get this return value? = btService.getQuote("bidu")

Any suggestion must be appreciated.

Feb 6 '06 #1
10 6504
Something like this:-

Dim aoBTQuote
Dim oBTQuote

aoBTQuote = btService.getQuote("bidu")

For Each oBTQuote In aoBTQuote
'do stuff with oBTQuote
Next
Anthony.

Feb 6 '06 #2
Hi, it threw out a error.
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch

in this line: For Each oBTQuote In aoBTQuote

and by using Response.write typename(aoBTQuote), I get unknown() type.

does that mean I cannot get the array typed return value?

thanks

Johnson

Feb 7 '06 #3
I make another test by change the return type of my web method to
BTQuote, and my asp code as follows

Dim oBTQuote
Set btService = Server.CreateObject("BTLib2.BTDemoService")
oBTQuote = btService.GetQuote("bidu")
Response.write typename(oBTQuote)
Response.write oBTQuote

The result is shown as:
String
BTLib2.BTQuote

I don't know why this happens, the method must return a BTQuote value,
but instead, it returns a string which indicates the actual type of the
return value, anyone know why? thank

Ocean

Feb 7 '06 #4
It worked if I changed the third line to
Set oBTQuote = btService.GetQuote("bidu") !!!!!

But still got problem when return an array of BTQuote, the typename()
still get Unknown() :(

Feb 7 '06 #5
It worked if I changed the third line to
Set oBTQuote = btService.GetQuote("bidu") !!!!!
But still got problem when return an array of BTQuote, the typename()
still get Unknown() :(

Ocean

Feb 7 '06 #6
Here is another test I've made. I encapsulate the array of BTQuote into
the BTResult class, then changed the return type to BTResult.

by running following code,
Set btService = Server.CreateObject("BTLib4.BTDemoService")
Set oBTResult = btService.GetQuote("bidu")
Response.write typename(oBTResult.btquotes) // the btquotes field
contains the array

I got
Object()

is this normal? shouldn't it be Variant()?
thanks

Ocean

Feb 7 '06 #7
ps, by change the code to
Response.write IsArray(oBTResult.btquotes)

i got "true" !!! but how can I access it as a array? using for loop, it
threw out a type mismatch error

Feb 7 '06 #8
Can you use VarType() on the array instead. What value do you get?

Can you loop through the array like this:-

Dim i

For i = LBound(aoBTQuote) to UBound(aoBTQuote)
Set oBTQuote = aoBtQuote(i)
' Do stuff
Next

Feb 7 '06 #9
Hi, Anthony
VarType() returns 8201 which indicates it is an array, by the way, I
can get its ubound also.

But I can't access the element in the array by any approach, which
nearly drives me nuts.
your suggestion seems to work, but it still will crash at
"aoBtQuote(i)", cuz I cannot use this way to access the element, it
will throw a type mismatch error.

I got some reference here:
http://support.microsoft.com/kb/q174576/
http://www.dotnet247.com/247referenc...42/211620.aspx

maybe they will help, but still don't know how to do, would you please
give me some advice according to the refs? thank you very much,
Anthony!!!

Ocean

Feb 7 '06 #10
Yes it does look like you should follow the advice of the Q174576.

The vartype of the array indicates that it is an array of objects.

So try making the return type of the method a variant and have the array
returned by an array of variants.

Anthony.
Feb 7 '06 #11

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

Similar topics

0
by: the gullers | last post by:
I am trying to return an array of strings (basicaly the contents of the textfield) to the main class... when i put this piece of code it tells me that i need to declare the array of strings final...
0
by: Marc van Boven | last post by:
I'm stuck with the following problem: My nusoap-client calls a server-function giveCombination(). The function giveCombination should return something like array( => array( 'a_id' => 6,...
59
by: Michael C | last post by:
eg void DoIt() { int i = FromString("1"); double d = FromString("1.1"); } int FromString(string SomeValue) {
1
by: Thomas D. | last post by:
Hello all, I'm using the IXmlSerializable interface for a project and encounter some problems when testing my webservice in a client application. I know this interface is undocumented and not...
5
by: Sam | last post by:
Hi All I have couple of question regarding property of a class and structures. **** ---- Here is my class and structure ---- ***** 1. Public Structure MyPoint 2. Dim p As Point 3. ...
8
by: WakeBdr | last post by:
I'm writing a class that will query a database for some data and return the result to the caller. I need to be able to return the result of the query in several different ways: list, xml,...
10
by: Raj | last post by:
I need a VB function to return array of collections like Private Type Employee empname as string address as string salary as integer deptno as integer End Type dim employees() as Employee
3
by: BombDrop | last post by:
Can any one help I have a method that will return a List to be bound as a datasource to a combobox see code for population below. I get the following error when i try to compile Error 29 ...
8
by: Sundhas | last post by:
I made a Webservice Operation whose return type is STRING Following is the code @WebMethod(operationName = "authorize") public String authorize(@WebParam(name = "Username") String Username) { ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.