Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > How to get the return value(array type) of a webservice method in ASP

Reply
Thread Tools

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

 
 
Ocean
Guest
Posts: n/a
 
      02-06-2006
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.

 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      02-06-2006
Something like this:-

Dim aoBTQuote
Dim oBTQuote

aoBTQuote = btService.getQuote("bidu")

For Each oBTQuote In aoBTQuote
'do stuff with oBTQuote
Next


Anthony.



 
Reply With Quote
 
 
 
 
Ocean
Guest
Posts: n/a
 
      02-07-2006
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

 
Reply With Quote
 
Ocean
Guest
Posts: n/a
 
      02-07-2006
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

 
Reply With Quote
 
Ocean
Guest
Posts: n/a
 
      02-07-2006
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()

 
Reply With Quote
 
Ocean
Guest
Posts: n/a
 
      02-07-2006
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

 
Reply With Quote
 
Ocean
Guest
Posts: n/a
 
      02-07-2006
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

 
Reply With Quote
 
Ocean
Guest
Posts: n/a
 
      02-07-2006
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

 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      02-07-2006
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



 
Reply With Quote
 
Ocean
Guest
Posts: n/a
 
      02-07-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Asynchronous Call of WebService method within a WebService RenÚ Preu▀ler ASP .Net Web Services 0 10-29-2008 11:55 AM
Get return value from an asp.net webservice.. Paul ASP .Net Web Services 3 08-13-2008 10:27 AM
Can a webservice method return more than field value? Jonathan ASP .Net 4 07-09-2008 10:32 AM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM



Advertisments