By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

What data types are SOAP serializable

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
// 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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.