Export (0) Print
Expand All

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

This topic is specific to a legacy technology. XML Web services and XML Web service clients should now be created using Windows Communication Foundation .

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 a Web service that is accessible to any client application.

To ensure the broadest reach, 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 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 language C++ Common language runtime

base64Binary

Byte[]

boolean

bool

Boolean

byte

char, __int8

SByte

double

double

Double

dateTime

DateTime

decimal

   

Decimal

float

float

Single

int

int, long, __int32

Int32

long

__int64

Int64

QName

   

XmlQualifiedName

short

short, __int16

Int16

string

BSTR

String

time

   

DateTime

unsignedByte

unsigned __int8

Byte   

unsignedInt

unsigned __int32

UInt32

unsignedLong

unsigned __int64

UInt64

unsignedShort

unsigned __int16

UInt16

Arrays of primitives and enums

Arrays 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 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.

Type Description

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 types

From the client's perspective, enumeration types become classes with a static constant string field for each value.

Arrays of primitives, enums

Arrays of the above.

The data types supported by 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, Web services using the SOAP protocol support the following additional data types.

Type Description

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 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

Community Additions

ADD
Show:
© 2015 Microsoft