Web-Services with a Collection of a custom object

H

hellrazor

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.XmlSerializationReader1.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
 
H

hellrazor

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.XmlSerializationReader1.R
ea 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

Following up an extra bit of info:

The collection (or array) is supposed to contain three instances of a
custom object called PsmWsResult, which has two variable members: code,
and description.

Thanks!
 
H

hellrazor

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.XmlSerializationReader1.R
ea 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

Following up an extra bit of info:

The collection (or array) is supposed to contain three instances of a
custom object called PsmWsResult, which has two variable members: code,
and description.

Thanks!

.... and furthermore yet, this is where the debugger halts:

-------------------------------
[System.Web.Services.Protocols.SoapRpcMethodAttribute
("http://www.CollectionWsInterface.com/CollectionWsInterface-
interface/getCollectio" +
"n", RequestNamespace="urn:CollectionWsInterface",
ResponseNamespace="urn:CollectionWsInterface")]
[return: System.Xml.Serialization.SoapElementAttribute("outMsgText")]
public PsmWsCollection getCollection() {

//debugger breaks at the following line!

object[] results = this.Invoke("getCollection", new object[0]);
return ((PsmWsCollection)(results[0]));
}
-------------------------------
 
J

Jorge Ayala

Hello hellrazor.

I have the same problem, searching in tons of references I found that there
is a bug in the implementation of the compact framework, when a web service
exposes an array ob Objets, the pocket pc just cannot get it. I downloaded
the service pack 3 for the compact framework but it didn´t work.

If you find an answer to this problem I will apreciate it, and If I finf one
i will notify you.

regards
Jorge Ayala
(e-mail address removed)

hellrazor said:
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.XmlSerializationReader1.R
ea 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

Following up an extra bit of info:

The collection (or array) is supposed to contain three instances of a
custom object called PsmWsResult, which has two variable members: code,
and description.

Thanks!

.... and furthermore yet, this is where the debugger halts:

-------------------------------
[System.Web.Services.Protocols.SoapRpcMethodAttribute
("http://www.CollectionWsInterface.com/CollectionWsInterface-
interface/getCollectio" +
"n", RequestNamespace="urn:CollectionWsInterface",
ResponseNamespace="urn:CollectionWsInterface")]
[return: System.Xml.Serialization.SoapElementAttribute("outMsgText")]
public PsmWsCollection getCollection() {

//debugger breaks at the following line!

object[] results = this.Invoke("getCollection", new object[0]);
return ((PsmWsCollection)(results[0]));
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top