Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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
Reply With Quote
  #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
Reply With Quote
  #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.
Reply With Quote
  #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
Reply With Quote
  #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.
Reply With Quote
  #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????
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:58 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.