Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm just wondering what the best practice for Web Service design is. For example, lets say I am creating an RSS Reader.

 

If I were creating a Class Library (dll) project, I would have two classes.

1) A class to download and process RSS XML feeds.

2) A Data class to hold all the data (Title, Description, OriginalURL, etc)

 

Now the first class would have a method like GetRSS(String URL) and it would return an array of the data class (arraylist, collection or something along these lines); however, with a Web Service I cannot return an arraylist of User Defined Objects, so what is the best practice?

 

Secondly, what is the best organization of code in a 2005 Web Service, and how do I reference it in my client application?

 

For example, I have these two classes above, so that creates two *.asmx files, with two separate .cs files in the App_Code directory. In the client, do I make a reference to both .asmx files?

 

Thanks in advance!

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

Add a parameterless constructor

 

however, with a Web Service I cannot return an arraylist of User Defined Objects

 

I have never had a problem returning arrays of my own classes from a web service. The only constraint I have come across is that the class must have a parameterless constructor (for serialization).

 

Good luck :)

Never trouble another for what you can do for yourself.
Posted

Yes, as a work around I have been able to use an Array, but I was unable to use an ArrayList, or a Strongly Typed Collection, which inherits from CollectionBase.

 

As a side question, in a Class Library, if I have an object with an override string ToString() method, if I set the Datasource property of a listbox to an Strongly Typed Collection, it calls my ToString method, however, with a Web Service, my ToString method is overlooked, and the text that shows up in the list box is something like "ProgramName.Namespace.ClassName" instead of what should have been returned by the ToString(). Is this a feature of webservices or am I doing something incorrectly?

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted (edited)

Is there another way to emulate this functionality, without rewriting the code inside the Web Service?

 

Also, if I need to have more than 1 class in a web service, should I have multiple .asmx files and multipal .cs files in the App_Code. Then in the client, just reference ALL of the .asmx files individually? is there a way to group them all into one Web Reference for the Client?

Edited by Nate Bross

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...