This documentation is archived and is not being maintained.

Data Types Supported by XML Web Services Created Using ASP.NET

All programming languages specify various data types in which to store different kinds of data. The simple, or primitive, data types are fairly similar across programming languages. However, there are subtle differences that prevent direct mapping between languages. These differences present a challenge to creating an XML Web service that is accessible to any client application.

To ensure the broadest reach, XML Web services support an assortment of primitive data types that can be encoded and serialized using XML.

The following table shows the primitive data types supported by XML Web services, which are the data types outlined in the second part of the XML Schema definition (XSD) language, along with the equivalent data types in C++ and the common language runtime.

XML Schema definition languageC++Common language runtime
BooleanboolBoolean
Bytechar, __int8   
DoubledoubleDouble
Datatypestruct   
Decimal   Decimal
EnumerationenumEnum
FloatfloatSingle
Intint, long, __int32Int32
Long__int64Int64
Qname   XmlQualifiedName
Shortshort, __int16Int16
StringBSTRString
TimeInstant   DateTime
UnsignedByteunsigned __int8   
UnsignedIntunsigned __int32UInt32
UnsignedLongunsigned __int64UInt64
UnsignedShortunsigned __int16UInt16
Arrays of primitives and enumsArrays of the above types

For information on converting from common language runtime data types to data types in other languages, such as C# and Visual Basic .NET, see .NET Framework Class Library.

The available data types depend on the protocol that the XML Web service uses. For example, HTTP-GET and HTTP-POST protocols are both limited to name/value pairs. However, SOAP allows for a richer use of XML to encode and serialize complex data structures such as classes.

The following table shows the supported types for HTTP-GET and HTTP-POST.

TypeDescription
Primitive types (limited)The following primitive types are converted into name/value pairs represented as strings: Boolean, Currency, DateTime, Decimal, Double, Int16, Int32, Int64, Single, String, UInt16, Uint32, and UInt64.
Enum typesFrom the client's perspective, enumeration types become classes with a static constant string field for each value.
Arrays of primitives, enumsArrays of the above.

The data types supported by XML Web services when the SOAP protocol is used are directly correlated with the data types that can be serialized into XML. ASP.NET serializes and deserializes XML using the XmlSerializer class. For details on the types that are supported by XmlSerializer, see Introducing XML Serialization.

In addition to the primitive types listed in the preceding table, XML Web services using the SOAP protocol support the following additional data types.

TypeDescription
Classes and structs,
Arrays of classes and structs
Class and struct types with public fields or properties. The public properties and fields are serialized. Classes must have a default constructor that does not accept any parameters.
DataSet,
Arrays of DataSet
ADO.NET DataSet types. Dataset types can also appear as fields in classes or structs.
XmlNode,
Arrays of XmlNode
XmlNode is an in-memory representation of an XML fragment. XmlNodes types can be passed as parameters or return values, and they are added to the rest of the XML passed to the XML Web service in a SOAP-compliant manner. This enables you to pass or return XML even if its structure changes from call to call, or if you do not know all the types being passed. XmlNode types can also appear as fields in classes or structs.

See Also

Introducing XML Serialization | .NET Framework Class Library | Building XML Web Services Using ASP.NET | Building XML Web Service Clients

Show: