webservice failure

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi again,

I tried to declare the following function on my webservice

<WebMethod()> Public Sub mytestfunc() as Object()
return myarraylist.ToArray() 'myarraylist is of type ArrayList
End Sub

This compiles correctly, but when I try to call it in my web client, I
receive a SOAP error, that indicates that the type the arraylist really
consists of (e.g. MYSTRUCT) is not defined.
Now, how can I transfer an array of structures as a return value of a
webmethod?

Thanks
Peter
 
Peter Schmitz said:
I tried to declare the following function on my webservice

<WebMethod()> Public Sub mytestfunc() as Object()
return myarraylist.ToArray() 'myarraylist is of type ArrayList
End Sub

This compiles correctly, but when I try to call it in my web client, I
receive a SOAP error, that indicates that the type the arraylist really
consists of (e.g. MYSTRUCT) is not defined.
Now, how can I transfer an array of structures as a return value of a
webmethod?

I *believe* that you need to use SoapIncludeAttribute. I haven't used
it myself, but I ran across it looking at the various Soap attributes.
 
Yes, if there's going to be a downcast on the server, the plumbing needs
to pass the xsi:type="YourStruct" XML attribute, then on the server it'll
use that to match the CLR attribute to know which class to create & use.
Oh, I just noticed this is a return value -- well, same thing in reverse :)

Why not just make your Webmethod return that type as a return value (instead
of object)? If it need to be polymorphic then I guess that's ok, but if it's
always returning that type, I'd go with the stronger typing.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Back
Top