Hi there,
I'm trying to consume a web-service that is supposed to return a
collection of a custom object. The web-service was not created with C# or
VS.net. It was created with IBM VisualAge Smalltalk 6. I haven't had
problems consuming other web-services but c# seems to choke with
"Collection " return types.
If you'd like to try to see an example of this problem you can add the
following web-reference to your project:
http://216.18.68.93:9999/CollectionWsInterface.wsdl
(The browser window will say that there are no functions found, but they
are there)
After adding the web-reference and renaming it "CollectionsTes t", I
created a plain vanilla windows app and inserted the following into the
form load event:
CollectionsTest .CollectionWsIn terface ws =
new CollectionsTest .CollectionWsIn terface();
//PsmWsCollection seems to be the return object
//which is supposed to be a collection.
CollectionsTest .PsmWsCollectio n wsCollection;
wsCollection = ws.getCollectio n();
At this point, the debugger halts execution. The first lines of the stack
trace:
-------------------------------
Unhandled Exception: System.InvalidO perationExcepti on: There is an error
in XML document (16, 14). ---> System.InvalidC astException: Cannot assign
object of type WindowsApplicat ion3.Collection sTest.PsmWsResu lt to an
object of type WindowsApplicat ion3.Collection sTest.PsmWsResu lt[].
at
Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onReader1.Rea
d1_PsmWsCollect ion()
-------------------------------
Which leads me to believe that the collection is being returned as an
array itself. I'm stuck at this point, how do I cast the return type to
be an array of itself??
If I try the following:
wsCollection = (CollectionsTes t.PsmWsCollecti on[])ws.getCollecti on();
I get a "Cannot convert type" error when compiling.
I tried invoking the getCollection function using "Web Service Studio"
and it chokes on it as well!
If anyone has any clue on what I should do to correct this, I'd
appreciate it!
Thanks!
Jorge