Convert Java Arraylist return from Java WebService to C# Arraylist

Posted by TTCG on Stack Overflow See other posts from Stack Overflow or by TTCG
Published on 2010-03-17T22:02:17Z Indexed on 2010/03/17 22:41 UTC
Read the original article Hit count: 608

Filed under:
|
|
|

In my C# program, I would like to consume the Java Web Service Method which replies the java.Util.ArrayList. I don't know how to convert the Java ArrayList to C# ArrayList.

This is Java Codes

@WebMethod
@WebResult(name = "GetLastMessages")
@SuppressWarnings("unchecked")
public ArrayList<Message> getLastMessages(@WebParam(name = "MessageCount")int count) {
    ....
            ....
    return messages;
}

This is C# Codes

MessagesService.MessagesService service = new MessagesService.MessagesService();
System.Collections.ArrayList arr = (System.Collections.ArrayList)service.getLastMessages(10);

I got the following Error in C#

Cannot convert type 'WindowsFormsApplication1.MessagesService.arrayList' to 'System.Collections.ArrayList'  

How can I cast these Java ArrayList to C# ArrayList

© Stack Overflow or respective owner

Related posts about web-services

Related posts about c#