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 "CollectionsTest", I
created a plain vanilla windows app and inserted the following into the
form load event:
CollectionsTest.CollectionWsInterface ws =
new CollectionsTest.CollectionWsInterface();
//PsmWsCollection seems to be the return object
//which is supposed to be a collection.
CollectionsTest.PsmWsCollection wsCollection;
wsCollection = ws.getCollection();
At this point, the debugger halts execution. The first lines of the stack
trace:
-------------------------------
Unhandled Exception: System.InvalidOperationException: There is an error
in XML document (16, 14). ---> System.InvalidCastException: Cannot assign
object of type WindowsApplication3.CollectionsTest.PsmWsResult to an
object of type WindowsApplication3.CollectionsTest.PsmWsResult[].
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Rea
d1_PsmWsCollection()
-------------------------------
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 = (CollectionsTest.PsmWsCollection[])ws.getCollection();
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