473,608 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Web Service returning types - BIG PROBLEMS

Hello,

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:

[WebMethod]
[XmlInclude(type of(Tender)), XmlInclude(type of(Offer)),
XmlInclude(type of(Product))]
public ArrayList GetTenders(stri ng user, string password)

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

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;

#endregion

#region Constructors

public Tender()
{
this.name = "";
this.surname = "";
this.hospital = "";
this.tenderID = "";
this.productLis t = 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.productLis t = new ArrayList();
this.offerList = new ArrayList();
}
#endregion
// 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 2060
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.
http://bleahbleah.com/folder/peter.asmx

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

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4213
by: Burak | last post by:
Hello, I have a web service that has a two user defined public classes. For sake of brevity, I'll write them as follows Public Class Service1 Public Class Class1 Public x as integer End Class
2
1473
by: Tarren | last post by:
Hi: What would be some standard convention to follow when writing web services for return types for .NET only data types? I initially wrote my web service that returns some XML as System.XML.XMLDocument and some lists as System.Data.Datasets. I realized this would be precluding any non-.NET apps from using it. Is it generally considered OK to have web services take and return data types that are .NET only? Doesn't it negate the...
2
8801
by: RJ | last post by:
I've been trying to find documentation that explains limitation of possible types that a webmethod can return. I realize xml serialization must take place to return the specified type. Must the return type of a webmethod implement ISerializable? I saw something about using SoapInclude or XMLInclude attribute to include other types in web services. Does this imply that it is possible to return any type, even some third party class? ...
2
1901
by: Anthony Biondo Jr | last post by:
I was wondering how to handle an error in a web service. If our web service encounters a connection error or any other error what is the best practice for returning an error? Do you return a blank result with an error attached or is there some other way to do this? thanks, Anthony
5
4963
by: Jim Murphy | last post by:
In creating a C# web service, I am having trouble returning a DataTable object as the result of a web method. I have no problem returning native types like string or int, but cannot return a .NET DataTable object. The problem occurs when I try to compile the client side C# application (it complains about the DataTable type not being recognized as the return of the web service method). Thanks
0
1234
by: andreas.baus | last post by:
Hi. I created a web service (using Apache Axis) and a client for accessing it (using .NET 1.1, C# and WSE2.0), and I noticed a strange phenomenon: When the service sends it's responses using the multiref method for serializing complex data types, the client receives them without a problem. If I however set the service to send *without* multiref, the .NET side seems to be no longer able to properly deserialize the data, instead returning...
3
6608
dmjpro
by: dmjpro | last post by:
plz send me a good link which can clearify me how the J2EE framework works i want the details information .... plz help thanx
0
1354
ntxsoft
by: ntxsoft | last post by:
Hello everybody, I have a small problem while returning array from web service. Firstly I'm new at java web services and I'm using netbeans 6 with glassfish 2. The problem is I have a class, name is "Experience" and I want to return Experience array from service. In web service I implement like that @WebMethod(operationName = "getExperience") public Experience getExperience( @WebParam(name = "user") User user, ...
5
2674
by: ctj951 | last post by:
I have a very specific question about a language issue that I was hoping to get an answer to. If you allocate a structure that contains an array as a local variable inside a function and return that structure, is this valid? As shown in the code below I am allocating the structure in the function and then returning the structure. I know if the structure contained only simple types (int, float) this will work without problems as you...
0
8059
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8470
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6815
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4023
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.