470,822 Members | 1,222 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,822 developers. It's quick & easy.

Web Service returning types - BIG PROBLEMS


I really hope that someone will be able to help me, because I'm desperate now!

I'm a student, graduating this year, and I'm working on a thesis where C#
Web Services are involved. I only have three weeks to finish it all!

My GUI and Web services were finished, but I hadn't tested them. So I linked
the GUI to the Web service and started testing them.

From the GUI, I called the Web service method:

[XmlInclude(typeof(Tender)), XmlInclude(typeof(Offer)),
public ArrayList GetTenders(string user, string password)

This method all tenders out of a database, and sends them back in an

The class Tender looks like this:

public class Tender
#region Private fields

private string name;
private string surname;
private string hospital;
private string tenderID;
private DateTime date;
private DateTime dateLimit;
private ArrayList productList;
private ArrayList offerList;


#region Constructors

public Tender()
this.name = "";
this.surname = "";
this.hospital = "";
this.tenderID = "";
this.productList = new ArrayList();
this.offerList = new ArrayList();

public Tender(string name, string surname, string hospital, DateTime date,
DateTime dateLimit, string tenderID)
this.name = name;
this.surname = surname;
this.hospital = hospital;
this.date = date;
this.dateLimit = dateLimit;
this.tenderID = tenderID;
this.productList = new ArrayList();
this.offerList = new ArrayList();
// Getters and setters

The problem is that I receive an array containg arrays of XmlNodes as
returning value of the Web Service method GetTenders.

I really need the help from someone to solve this problem, and be able to
get the tender information back from the web service instead of the XmlNodes.

I've read several related questions in this discussion group, but none of
them helped me! I hope someone can help me!

Nov 23 '05 #1
1 1925
What you should be doing is not returning an ArrayList but you should
be returning Tender[] or whatever object you need. This assumes that
you are consuming your web service via a Web Reference. If not please
follow the instructions provided at the bottom.
Any object that needs to be used on both the web service and client
that is an ArrayList should not be an arraylist but should be the
strongly typed object and should be exposed as a property. This causes
the increased headache of adding the items to the arraylist and then at
the last minute creating an ArrayOfObject[] that is the appropraite
size and then copying the Items over. This will however ensure that the
client can get the objects easily and effortlessly.

Hope this helps
What your client project needs to do is to add a Web Reference.
In your client project go to Project -> Add Web Reference. Type in the
URL that your Web Service is located at.

There is a text box that will have a default value of "WebReference" if
memory serves me right.
Any classes that are publicly exposed via the

Nov 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Anthony Biondo Jr | last post: by
3 posts views Thread by dmjpro | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.