473,385 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Return complex data type from a web method

Hi,

I am implementing web services and try to return a collection of records,
say

1,"John","Doe",1/1/1990
2,"Jane","Doe",2/1/1990
3,"Joe","Smith",3/1/1990
.......

In my c# project I have a class that implements ICollection to provide these
data.

When I try to make web method to return the class, I got :
The return type of .... is not CLS-compliant.

What is the best way to return a collection of records from a web method?

TIA
Nov 13 '06 #1
2 5440
Create a "Record" class with fields corresponding to the CSV data you posted,
and mark it as serializable. Your webservice will be happy to return an array
of these.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"John" wrote:
Hi,

I am implementing web services and try to return a collection of records,
say

1,"John","Doe",1/1/1990
2,"Jane","Doe",2/1/1990
3,"Joe","Smith",3/1/1990
.......

In my c# project I have a class that implements ICollection to provide these
data.

When I try to make web method to return the class, I got :
The return type of .... is not CLS-compliant.

What is the best way to return a collection of records from a web method?

TIA
Nov 13 '06 #2
Your question tells us what your data looks like, but nothing about
what the return type of your function is. Can you post the signature of
the web service-visible method, as well as an outline of any
non-framework types that may be used in that signature?

As for the "best way" to do it, that's probably to create a shell
return type struct or class and dump that. The web service framework
will automatically serialize it as XML:

public struct myReturnType
{
public int ID;
public string FirstName;
public string LastName;
public DateTime Date;
}

If your method has the following signature:

[WebMethod]public myReturnType[] GetRecords(...) { ... }

you'll get back something vaguely like:

<GetRecords>
<myReturnType>
<ID>1</ID>
<FirstName>John</FirstName>
...
</myReturnType>
<myReturnType>
<ID>2</ID>
...
</myReturnType>
...
</GetRecords>

That's about the best way to use web services.
Stephan

John wrote:
Hi,

I am implementing web services and try to return a collection of records,
say

1,"John","Doe",1/1/1990
2,"Jane","Doe",2/1/1990
3,"Joe","Smith",3/1/1990
......

In my c# project I have a class that implements ICollection to provide these
data.

When I try to make web method to return the class, I got :
The return type of .... is not CLS-compliant.

What is the best way to return a collection of records from a web method?

TIA
Nov 13 '06 #3

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

Similar topics

24
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing the code. Thank you. .. Facundo
1
by: Geoff Biggs | last post by:
Evening all, I'm trying to add a new built-in number data type to Python with its own syntax, so I'm working directly with the interpreter rather than creating my own extension module (side...
3
by: aaa | last post by:
I am having trouble getting a complex data type to get passed to a non-COM dll's function by ref and return back data from that object. Simple data types work fine but when I try the complex data...
2
by: Jerod Hatley | last post by:
Can someone point me to a good document on creating and passing complex datatypes to and from a web service? I would like to pass a master / detail object. The object would hold the master...
2
by: emma_middlebrook | last post by:
Hi <ClubNight Name = "Go club" Date = "2006-09-09"> Discussed a few simple proverbs. <Attendee Name = "RJ"/> <Attendee Name = "TT"/> <Attendee Name = "RB"/> </ClubNight> I'm trying to work...
1
by: Daxter77 | last post by:
PHP 5.2.2 Apache 2.2 Windows XP (dev environment) I'm attempting to set up a soap server in PHP 5 and I've been succesfull in getting a simple function to work, the problem is I want to return...
3
by: =?Utf-8?B?SlA=?= | last post by:
Explanation: We have several SP that need to retrieve a single "Default Photo" from one of several Photo tables. The column in question in these tables is defined as an IMAGE data type. I...
0
by: Abhishek Saha | last post by:
Suppose my response message can be like this <Response> <ResponseCode>false</ResponseCode> <ResponseMessage>reason 1</ResponseMessage> <ResponseMessage>reason 2</ResponseMessage>...
0
by: ranjtih kumar | last post by:
Hi, I have created webservices using asp.net. Some of the web methods are taking complex data types (for ex.CreateQuery() webmethod is taking QueryEntity object ). Now iam planning to call these...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.