Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 12th, 2005, 12:40 PM
Authorized User
 
Join Date: Mar 2004
Location: Maumee, OH, USA.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Complex Data Type

Is there a way to allow Web Services to accept complex data types such as Arraylists, hashtables, and user defined types? Likewise, is it possible for them to return these types as a result?

Thanks in advance.
Brian
  #2 (permalink)  
Old May 12th, 2005, 12:54 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It most certainly is possible. When you have a web method that accepts or returns a complex type the WSDL that get generated has definitions for those types. When you set up a web reference to that web service, the proxy class file will have stub classes (built off the WSDL) that outline your complex types (even those you define). When you call the web service methods via the proxy class you interact with them in the same way you would interact with the actual methods of the actual web service class.

-Peter
  #3 (permalink)  
Old May 12th, 2005, 01:44 PM
Authorized User
 
Join Date: Mar 2004
Location: Maumee, OH, USA.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm still pretty new to this whole web service thing. I only grasped part of what you stated in your post.

All I know is that if I create a web service called "Test" with the following signature:

<WebService()> Public Function Test(byval x as arraylist, byval y as object) as Hashtable

I end up recieving the following message - The type Systems.Collection.Hashtable is not supported because it implements IDictionary.
  #4 (permalink)  
Old May 12th, 2005, 01:56 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Do you mean "<WebMethod()>"?

I just created a new web service with a method like this:

<WebMethod()> Public Function Test(ByVal x As ArrayList, ByVal y As Object) As Hashtable

And it compiled fine.

-Peter
  #5 (permalink)  
Old May 12th, 2005, 02:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am also pretty new to all this web service stuff, and also new to the remoting world, at least in C# and .NET. However I think I managed to serialize a Hashtable the other day... Here is the code
Code:
    [Serializable]
    public class Hasher : Hashtable, ISerializable 
    {
        public Hasher()
        {

        }

        public Hasher(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator i = info.GetEnumerator();
            while(i.MoveNext())
                this.Add(i.Name, i.Value);
        }

        void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
        {
            IDictionaryEnumerator i = this.GetEnumerator();
            while(i.MoveNext())
                info.AddValue((string)i.Key, i.Value);
        }        
    }
    I may be worng, so please correct me if this is not the right way to do it.

Hope it helps, Jacob.
  #6 (permalink)  
Old May 12th, 2005, 02:30 PM
Authorized User
 
Join Date: Mar 2004
Location: Maumee, OH, USA.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oooppss...yes I meant <WebMethod()> The Webservice itself will compile fine it's when I try to update the web reference in the application (an ASP.NET app) that I get the error. Thoughts????


Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Method Returning a complex Custom data type. saisunil1978 .NET Web Services 0 July 15th, 2008 05:38 AM
What is '{no name}' is 'empty' in complex type? 2BOrNot2B XML 2 March 26th, 2008 04:35 PM
Complex Data Structures misterqj General .NET 2 March 19th, 2005 04:40 AM
unordered elements in complex type mandabear XML 0 September 3rd, 2004 11:08 AM
Data Type error but it is the correct type Mitch SQL Server 2000 2 March 19th, 2004 11:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.