Advertisement

05.04.2008 at 08:47PM PDT, ID: 23375655
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

How can I create and consume a webservice that returns ArrayList

Asked by brepetti in Microsoft Visual C#.Net, .Net Application Servers, .NET Framework 3.x versions

Tags:

I cant figure this out... I am able to create the webservice, but I cannot consume it for the life of me!

I created my web service by following this guide: http://geekswithblogs.net/azamsharp/archive/2006/02/15/69658.aspx

When I try to consume it, I get this error every single time:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:GetProductsResponse. The InnerException message was 'Error in line 1 position 319. Element 'http://tempuri.org/:anyType' contains data of the 'http://tempuri.org/:ProductInfo' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'ProductInfo' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

This is my first attempt at creating a web service that returns an array list and its driving me mad!

This is what my webservice looks like:

[WebMethod]
        [System.Xml.Serialization.XmlInclude(typeof(ProductInfo))]
        public ArrayList GetProducts()
        {
            return new StoreCatalog.CatalogController().GetProducts();

        }

this is how I am trying to consume the service:
 private void btnTest_Click(object sender, EventArgs e)
        {
                DServer.DServiceSoapClient client = new DClient.DServer.DServiceSoapClient();
                DServer.ArrayOfAnyType products = client.GetProducts();
         }



I have also attached a copy of the xml that is being produced.

I have googled this but the responses are very cryptic to me and I dont understand them.  I dont understand my problem so I guess thats why ;)  

Please can someone show me how to return an ArrayList properly!!!  If I cant use ArrayList, what is another alternative to passing a list of objects.

THANKS EXPERTS!



Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
<?xml version="1.0" encoding="utf-8" ?> 
- <ArrayOfAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
- <anyType xsi:type="ProductInfo">
  <P_Name>Blah Blah Blah</P_Name> 
  <P_ID>148470</P_ID> 
  </anyType>
- <anyType xsi:type="ProductInfo">
  <P_Name>Blah Blah Blah2</P_Name> 
  <P_ID>148471</P_ID> 
  </anyType>
 </ArrayOfAnyType>
 
Loading Advertisement...
 
[+][-]05.04.2008 at 11:15PM PDT, ID: 21498378

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, .Net Application Servers, .NET Framework 3.x versions
Tags: C#
Sign Up Now!
Solution Provided By: Jose_Jayan
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.05.2008 at 12:51AM PDT, ID: 21498624

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 08:27AM PDT, ID: 21508133

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628