Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2005

Tip: Looking for answers? Try searching our database.

Web-Services with a Collection of a custom object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hellrazor - 05 Jan 2005 19:25 GMT
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
hellrazor - 05 Jan 2005 19:33 GMT
> Hi there,
>
[quoted text clipped - 57 lines]
>
> 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!
hellrazor - 05 Jan 2005 21:48 GMT
>> Hi there,
>>
[quoted text clipped - 34 lines]
>> WindowsApplication3.CollectionsTest.PsmWsResult[].
>>    at

Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.R
>> ea d1_PsmWsCollection()
>> -------------------------------
[quoted text clipped - 26 lines]
>
> 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]));
}
-------------------------------
Jorge Ayala - 23 Feb 2005 00:03 GMT
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
jayala@siga.com.mx

> >> Hi there,
> >>
[quoted text clipped - 84 lines]
> }
> -------------------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.