473,472 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What data types are SOAP serializable

Hi,

As was pointed out whatever you return from a WebMethod needs to be
serializable to SOAP. An ArrayList is not serializable. I will be
needing to return other data types from web methods. Is there a
document, or can some one list those types that are not serializable
and the syntax for converting them?

Thanks
Whatever you return from a WebMethod needs to be serializable to SOAP. The
type ArrayList is not serializable to SOAP so it gets converted to an array
of objects (object[]) which is SOAP serializable (provided the objects in
the array are SOAP serializable).
2. What do I need to do to get an ArrayList on the receiving side? I
need to be able to resize the array. An Array can't be resized, the
ArrayList can.


ArrayList al = new ArrayList(WSR.ReadHistory(ItemPK));

Regards,
Sami


Nov 16 '05 #1
8 6273
My guess is, since Soap is nothing but SoapFormatter, anything that
implements ISerializable should be soap - serializable .. so arraylist
isn't, but HashTable is.

Or you could create a SerializableArrayList by inheriting from ArrayList,
and implementing ISerializable (or something like that).

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/

<xm******@yahoo.com> wrote in message
news:40**************@news.dslextreme.com...
Hi,

As was pointed out whatever you return from a WebMethod needs to be
serializable to SOAP. An ArrayList is not serializable. I will be
needing to return other data types from web methods. Is there a
document, or can some one list those types that are not serializable
and the syntax for converting them?

Thanks
Whatever you return from a WebMethod needs to be serializable to SOAP. Thetype ArrayList is not serializable to SOAP so it gets converted to an arrayof objects (object[]) which is SOAP serializable (provided the objects in
the array are SOAP serializable).
2. What do I need to do to get an ArrayList on the receiving side? I
need to be able to resize the array. An Array can't be resized, the
ArrayList can.


ArrayList al = new ArrayList(WSR.ReadHistory(ItemPK));

Regards,
Sami

Nov 16 '05 #2
Actually a hashtable isn't serializable through soap.

"Sahil Malik" <co*****************@nospam.com> wrote in message
news:u3**************@TK2MSFTNGP11.phx.gbl...
My guess is, since Soap is nothing but SoapFormatter, anything that
implements ISerializable should be soap - serializable .. so arraylist
isn't, but HashTable is.

Or you could create a SerializableArrayList by inheriting from ArrayList,
and implementing ISerializable (or something like that).

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/

<xm******@yahoo.com> wrote in message
news:40**************@news.dslextreme.com...
Hi,

As was pointed out whatever you return from a WebMethod needs to be
serializable to SOAP. An ArrayList is not serializable. I will be
needing to return other data types from web methods. Is there a
document, or can some one list those types that are not serializable
and the syntax for converting them?

Thanks
Whatever you return from a WebMethod needs to be serializable to SOAP. Thetype ArrayList is not serializable to SOAP so it gets converted to an arrayof objects (object[]) which is SOAP serializable (provided the objects inthe array are SOAP serializable).

> 2. What do I need to do to get an ArrayList on the receiving side? I
> need to be able to resize the array. An Array can't be resized, the
> ArrayList can.

ArrayList al = new ArrayList(WSR.ReadHistory(ItemPK));

Regards,
Sami


Nov 16 '05 #3
// Actually hashtable is serializable thru soap ... formatter is a
formatter.

using System;
using System.IO ;
using System.Collections ;
using System.Runtime.Serialization ;
using System.Runtime.Serialization.Formatters.Soap ;

namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Hashtable hsh = new Hashtable() ;

hsh.Add("Add an intrinsic",1) ;
hsh.Add("Add an object",new
System.Data.DataTable("unserializable_datatable")) ;
hsh.Add("It does work", DateTime.Now) ;

Stream stream = File.Open("c:\\trial.xml", FileMode.Create);
SoapFormatter formatter = new SoapFormatter() ;
formatter.Serialize(stream, hsh);
stream.Close();
}
}
}

trial.xml looks like -------->

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<a1:Hashtable id="ref-1"
xmlns:a1="http://schemas.microsoft.com/clr/ns/System.Collections">
<LoadFactor>0.72</LoadFactor>
<Version>3</Version>
<Comparer xsi:null="1"/>
<HashCodeProvider xsi:null="1"/>
<HashSize>11</HashSize>
<Keys href="#ref-2"/>
<Values href="#ref-3"/>
</a1:Hashtable>
<SOAP-ENC:Array id="ref-2" SOAP-ENC:arrayType="xsd:anyType[3]">
<item id="ref-4" xsi:type="SOAP-ENC:string">Add an intrinsic</item>
<item id="ref-5" xsi:type="SOAP-ENC:string">Add an object</item>
<item id="ref-6" xsi:type="SOAP-ENC:string">It does work</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-3" SOAP-ENC:arrayType="xsd:anyType[3]">
<item xsi:type="xsd:int">1</item>
<item href="#ref-7"/>
<item xsi:type="xsd:dateTime">2004-06-18T11:23:31.2857751-04:00</item>
</SOAP-ENC:Array>
<a3:DataTable id="ref-7"
xmlns:a3="http://schemas.microsoft.com/clr/nsassem/System.Data/System.Data%2
C%20Version%3D1.0.5000.0%2C%20Culture%3Dneutral%2C %20PublicKeyToken%3Db77a5c
561934e089">
<XmlSchema id="ref-9"><?xml version="1.0"
encoding="utf-16"?>
<xs:schema id="tmpDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="unserializable_datatable">
<xs:complexType>
</xs:complexType>
</xs:element>
<xs:element name="tmpDataSet"
msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded" />
</xs:complexType>
</xs:element>
</xs:schema></XmlSchema>
<XmlDiffGram id="ref-10"><diffgr:diffgram
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
/></XmlDiffGram>
</a3:DataTable>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- Sahil Malik
Independent Consultant
You can reach me thru my blog - http://dotnetjunkies.com/WebLog/sahilmalik/

"John Wood" <sp**@isannoying.com> wrote in message
news:ex**************@TK2MSFTNGP09.phx.gbl...
Actually a hashtable isn't serializable through soap.

"Sahil Malik" <co*****************@nospam.com> wrote in message
news:u3**************@TK2MSFTNGP11.phx.gbl...
My guess is, since Soap is nothing but SoapFormatter, anything that
implements ISerializable should be soap - serializable .. so arraylist
isn't, but HashTable is.

Or you could create a SerializableArrayList by inheriting from ArrayList,
and implementing ISerializable (or something like that).

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/

<xm******@yahoo.com> wrote in message
news:40**************@news.dslextreme.com...
Hi,

As was pointed out whatever you return from a WebMethod needs to be
serializable to SOAP. An ArrayList is not serializable. I will be
needing to return other data types from web methods. Is there a
document, or can some one list those types that are not serializable
and the syntax for converting them?

Thanks

>Whatever you return from a WebMethod needs to be serializable to SOAP.
The
>type ArrayList is not serializable to SOAP so it gets converted to an array
>of objects (object[]) which is SOAP serializable (provided the

objects in >the array are SOAP serializable).
>
>> 2. What do I need to do to get an ArrayList on the receiving side?

I >> need to be able to resize the array. An Array can't be resized, the >> ArrayList can.
>
>ArrayList al = new ArrayList(WSR.ReadHistory(ItemPK));
>
>Regards,
>Sami



Nov 16 '05 #4
oh weird, maybe my memory is failing me.
Was this always the case? (net 1.0 also?)
I definitely had *some* kinda problem with hashtable serialization with
either soap or binary formatters.
Unless I'm..losing..my...mind..

"Sahil Malik" <co*****************@nospam.com> wrote in message
news:eE*************@TK2MSFTNGP11.phx.gbl...
// Actually hashtable is serializable thru soap ... formatter is a
formatter.

using System;
using System.IO ;
using System.Collections ;
using System.Runtime.Serialization ;
using System.Runtime.Serialization.Formatters.Soap ;

namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Hashtable hsh = new Hashtable() ;

hsh.Add("Add an intrinsic",1) ;
hsh.Add("Add an object",new
System.Data.DataTable("unserializable_datatable")) ;
hsh.Add("It does work", DateTime.Now) ;

Stream stream = File.Open("c:\\trial.xml", FileMode.Create);
SoapFormatter formatter = new SoapFormatter() ;
formatter.Serialize(stream, hsh);
stream.Close();
}
}
}

trial.xml looks like -------->

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<a1:Hashtable id="ref-1"
xmlns:a1="http://schemas.microsoft.com/clr/ns/System.Collections">
<LoadFactor>0.72</LoadFactor>
<Version>3</Version>
<Comparer xsi:null="1"/>
<HashCodeProvider xsi:null="1"/>
<HashSize>11</HashSize>
<Keys href="#ref-2"/>
<Values href="#ref-3"/>
</a1:Hashtable>
<SOAP-ENC:Array id="ref-2" SOAP-ENC:arrayType="xsd:anyType[3]">
<item id="ref-4" xsi:type="SOAP-ENC:string">Add an intrinsic</item>
<item id="ref-5" xsi:type="SOAP-ENC:string">Add an object</item>
<item id="ref-6" xsi:type="SOAP-ENC:string">It does work</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-3" SOAP-ENC:arrayType="xsd:anyType[3]">
<item xsi:type="xsd:int">1</item>
<item href="#ref-7"/>
<item xsi:type="xsd:dateTime">2004-06-18T11:23:31.2857751-04:00</item>
</SOAP-ENC:Array>
<a3:DataTable id="ref-7"
xmlns:a3="http://schemas.microsoft.com/clr/nsassem/System.Data/System.Data%2 C%20Version%3D1.0.5000.0%2C%20Culture%3Dneutral%2C %20PublicKeyToken%3Db77a5c 561934e089">
<XmlSchema id="ref-9"><?xml version="1.0"
encoding="utf-16"?>
<xs:schema id="tmpDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="unserializable_datatable">
<xs:complexType>
</xs:complexType>
</xs:element>
<xs:element name="tmpDataSet"
msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded" />
</xs:complexType>
</xs:element>
</xs:schema></XmlSchema>
<XmlDiffGram id="ref-10"><diffgr:diffgram
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
/></XmlDiffGram>
</a3:DataTable>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- Sahil Malik
Independent Consultant
You can reach me thru my blog - http://dotnetjunkies.com/WebLog/sahilmalik/
"John Wood" <sp**@isannoying.com> wrote in message
news:ex**************@TK2MSFTNGP09.phx.gbl...
Actually a hashtable isn't serializable through soap.

"Sahil Malik" <co*****************@nospam.com> wrote in message
news:u3**************@TK2MSFTNGP11.phx.gbl...
My guess is, since Soap is nothing but SoapFormatter, anything that
implements ISerializable should be soap - serializable .. so arraylist
isn't, but HashTable is.

Or you could create a SerializableArrayList by inheriting from ArrayList, and implementing ISerializable (or something like that).

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/

<xm******@yahoo.com> wrote in message
news:40**************@news.dslextreme.com...
> Hi,
>
> As was pointed out whatever you return from a WebMethod needs to be
> serializable to SOAP. An ArrayList is not serializable. I will be
> needing to return other data types from web methods. Is there a
> document, or can some one list those types that are not serializable
> and the syntax for converting them?
>
> Thanks
>
> >Whatever you return from a WebMethod needs to be serializable to SOAP. The
> >type ArrayList is not serializable to SOAP so it gets converted to an array
> >of objects (object[]) which is SOAP serializable (provided the objects
in
> >the array are SOAP serializable).
> >
> >> 2. What do I need to do to get an ArrayList on the receiving
side? I > >> need to be able to resize the array. An Array can't be resized, the > >> ArrayList can.
> >
> >ArrayList al = new ArrayList(WSR.ReadHistory(ItemPK));
> >
> >Regards,
> >Sami
>



Nov 16 '05 #5
Instances of Hashtable are not serializable through a .asmx web service
page, because it uses XML serialization. You can use the SoapFormatter class
to serialize an arbitrary graph, but that's not the same thing.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com/blogs/mickey

"John Wood" <sp**@isannoying.com> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
oh weird, maybe my memory is failing me.
Was this always the case? (net 1.0 also?)
I definitely had *some* kinda problem with hashtable serialization with
either soap or binary formatters.
Unless I'm..losing..my...mind..

Nov 16 '05 #6
"Sahil Malik" <co*****************@nospam.com> wrote in message
news:u3**************@TK2MSFTNGP11.phx.gbl...
My guess is, since Soap is nothing but SoapFormatter, anything that
implements ISerializable should be soap - serializable .. so arraylist
isn't, but HashTable is.


This is not correct. The implementation of .asmx web services uses XML
serialization, not the SoapFormatter class and runtime serialization.
ISerializable has nothing to do with the XML serialization process.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com/blogs/mickey
Nov 16 '05 #7
Ah that'll be it then. thanks.

--
John Wood
EMail: first name, dot, second name at priorganize.com
"Mickey Williams" <my first name at servergeek.com> wrote in message
news:uo*************@TK2MSFTNGP11.phx.gbl...
Instances of Hashtable are not serializable through a .asmx web service
page, because it uses XML serialization. You can use the SoapFormatter class to serialize an arbitrary graph, but that's not the same thing.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com/blogs/mickey

"John Wood" <sp**@isannoying.com> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
oh weird, maybe my memory is failing me.
Was this always the case? (net 1.0 also?)
I definitely had *some* kinda problem with hashtable serialization with
either soap or binary formatters.
Unless I'm..losing..my...mind..


Nov 16 '05 #8
There is some confusion in this thread between full-fidelity runtime
serialization (which enlists the SoapFormatter or BinaryFormatter) and XML
serialization used by web services, which uses the XmlSerializer class.

An instance of ArrayList is certainly serializable with the XML serializer,
and therefore via an XML web method, as any simple experiment will
demonstrate. The response quoted by the OP is incorrect in several ways.

If you publish the web method and then consume it via a web reference, it
will be transformed into an array of object, but this has everything to do
with XML schema and the way that ArrayList is typed, and nothing to do with
ArrayList not being XML serializable. Since ArryaList is a universal donor
and acceptor of type object, its equivalent XML schema is a sequence of
xs:any. When Visual Studio sees a web service that includes a sequence of
xs:any, it turns it into an array of object. If you use a tracing tool (like
SoapScope or something similar), you'll see that the elements in the array
are serialized over the wire.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com/blogs/mickey
<xm******@yahoo.com> wrote in message
news:40**************@news.dslextreme.com...
Hi,

As was pointed out whatever you return from a WebMethod needs to be
serializable to SOAP. An ArrayList is not serializable. I will be
needing to return other data types from web methods. Is there a
document, or can some one list those types that are not serializable
and the syntax for converting them?

Thanks
Whatever you return from a WebMethod needs to be serializable to SOAP. Thetype ArrayList is not serializable to SOAP so it gets converted to an arrayof objects (object[]) which is SOAP serializable (provided the objects in
the array are SOAP serializable).
2. What do I need to do to get an ArrayList on the receiving side? I
need to be able to resize the array. An Array can't be resized, the
ArrayList can.


ArrayList al = new ArrayList(WSR.ReadHistory(ItemPK));

Regards,
Sami

Nov 16 '05 #9

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

Similar topics

0
by: xmail123 | last post by:
Hi, Hi, As was pointed out whatever you return from a WebMethod needs to be serializable to SOAP. An ArrayList is not serializable. I will be needing to return other data types from web...
1
by: jendra | last post by:
I'm new in using visual studio .net 2003 and web services. I found the web reference feature very useful and easy to use for handling web service methods which return simple types. However, i want...
2
by: Prakash | last post by:
Hi Friends, In my C# application, i have tried to serialize some structured data using Soapformatter. While calling the serialize funciton i got the exception message like "mscorlib....The...
6
by: DBC User | last post by:
Could someone help me understand 'Serializable'? What is this 'Serializable' why do we need it and how do we use it? Any link or simple example would be great.
2
by: (PeteCresswell) | last post by:
Seems like the toolkit does not handle complex data types. But that seems like much of the real world - once you get past something like just looking up a SIC code or adding two numbers. I see...
8
by: Richard Collette | last post by:
When attempting to debug a webservice, I get the error: Cannot serialize member System.Exception.Data of type System.Collections.IDictionary, because it implements IDictionary. In reading...
0
by: Thomas.Koerfer | last post by:
Hey guys, I googled for nearly 3 hours - but no result... We run a web-service and want to reach that service from Access. In the following part you see the wsdl content and the automatically...
1
by: BLUE | last post by:
I want to pass chunks of an xml file or an entire xml file to my WS. I'm surprised to see fro MSDN that no System.Xml class is serializable (XmlDocument, XmlElement and XmlNode): - I should use a...
0
by: Philluminati | last post by:
I have a Perl SOAP Server which returns this SOAP Message when invoked: <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance"...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.