Getting Started
  Introduction
  What is ASP.NET?
  Language Support

ASP.NET Web Forms
  Introducing Web Forms
  Working with Server Controls
  Applying Styles to Controls
  Server Control Form Validation
  Web Forms User Controls
  Data Binding Server Controls
  Server-Side Data Access
  Data Access and Customization
  Working with Business Objects
  Authoring Custom Controls
  Web Forms Controls Reference
  Web Forms Syntax Reference

XML Web services
   created using ASP.NET

  Introducing XML Web services
  Writing a Simple XML Web service
  XML Web service Type Marshalling
  Using Data in XML Web services
  Using Objects and Intrinsics
  The XML Web service Behavior
  HTML Pattern Matching

ASP.NET Web Applications
  Application Overview
  Using the Global.asax File
  Managing Application State
  HttpHandlers and Factories

Cache Services
  Caching Overview
  Page Output Caching
  Page Fragment Caching
  Page Data Caching

Configuration
  Configuration Overview
  Configuration File Format
  Retrieving Configuration

Deployment
  Deploying Applications
  Using the Process Model
  Handling Errors

Security
  Security Overview
  Authentication & Authorization
  Windows-based Authentication
  Forms-based Authentication
  Authorizing Users and Roles
  User Account Impersonation
  Security and WebServices

Localization
  Internationalization Overview
  Setting Culture and Encoding
  Localizing ASP.NET Applications
  Working with Resource Files

Tracing
  Tracing Overview
  Trace Logging to Page Output
  Application-level Trace Logging

Debugging
  The SDK Debugger

Performance
  Performance Overview
  Performance Tuning Tips
  Measuring Performance

ASP to ASP.NET Migration
  Migration Overview
  Syntax and Semantics
  Language Compatibility
  COM Interoperability
  MTS Transactions

Sample Applications
  A Personalized Portal
  An E-Commerce Storefront
  A Class Browser Application
  IBuySpy.com

  Get URL for this page

XML Web service Type Marshaling

This section illustrates that various data types can be passed to and returned from XML Web service methods. Because the XML Web services implementation is built on top of the XML Serialization architecture, it supports a significant number of data types. The following table lists the supported data types for XML Web service methods when using the SOAP protocol (for example, using the proxy generated by the Web Services Description Language tool, WSDL.exe).

TypeDescription
Primitive TypesStandard primitive types. The complete list of supported primitives are String, Char, Byte, Boolean, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, Double, Guid, Decimal, DateTime (as XML's dateTime), DateTime (as XML's date), DateTime (as XML's time), and XmlQualifiedName (as XML's QName).
Enum TypesEnumeration types, for example, "public enum color { red=1, blue=2 }"
Arrays of Primitives, EnumsArrays of the above primitives, such as string[] and int[]
Classes and StructsClass and struct types with public fields or properties. The public properties and fields are serialized.
Arrays of Classes (Structs)Arrays of the above.
DataSetADO.NET DataSet Types (see the next section for an example). DataSets can also appear as fields in structs or classes.

Note: Microsoft Visual Studio .NET and the XSD.EXE SDK utility have support for "strong-typing" a DataSet. These tools generate a class that inherits from DataSet to produce DataSet1, adding several methods/properties/etc that are specific to a particular XML schema. If you pass DataSet, XML Web services always transmits the schema along with the data (so it knows what tables and columns you are passing), and their types (for example, int, string). If you pass a subclass of DataSet (for example, DataSet1), XML Web services assumes you are adding tables/columns in the constructor, and assumes that those tables/columns represent your schema.

Arrays of DataSetArrays of the above.
XmlNode XmlNode is an in-memory representation of an XML fragment (like a lightweight XML document object model). For example, "<comment>This is<b>pretty</b> neat</comment>" could be stored in an XmlNode. You can pass XmlNodes as parameters, and they are added to the rest of the XML being passed to the XML Web service (the other parameters) in a SOAP-compliant manner. The same is true for return values. This allows you to pass or return XML whose structure changes from call to call, or where you may not know all the types being passed. XmlNode can also appear as fields in structs or classes.
Arrays of XmlNodeArrays of above.

Return values:

Whether calling a XML Web service using SOAP or HTTP GET/POST, all the above types are supported for return values.

Parameters:

Both by-value and by-reference (in/out) parameters are supported when using the SOAP protocol. By-reference parameters can send the value both ways: up to the server, and back to the client. When passing input parameters to a XML Web service using HTTP GET/POST, only a limited set of data types are supported, and they must be by-value parameters. The supported types for HTTP GET/POST parameters are listed below:

TypeDescription
Primitive Types (limited)Most standard primitive types. The complete list of supported primitives are Int32, String, Int16, Int64, Boolean, Single, Double, Decimal, DateTime, UInt16, UInt32, UInt64, and Currency. From the client's perspective, all these types turn into string.
Enum TypesEnumeration types, for example, "public enum color { red=1, blue=2 }". From the client's perspective, enums become classes with a static const string for each value.
Arrays of Primitives, EnumsArrays of the above primitives, such as string[] and int[]

The following example demonstrates the use of the types listed above, using a SOAP proxy generated from WSDL.exe. Note that because there is more than one public class defined in the .asmx file, you must specify which is to be treated as the XML Web service class using the "Class" attribute of the XML Web service directive:

<%@ WebService Language="C#" Class="DataTypes" %>

 
VB DataTypes.asmx

[Run Sample] | [View Source]
 
VB DataTypes.asmx?wsdl

[View Sample]

  • The SayHello method shows returning a String from a service.
  • The SayHelloName method returns a String, and also takes a String as a parameter.
  • The GetIntArray method shows how to return an array of integers.
  • The GetMode method returns an enum value.
  • The GetOrder method returns a class (which is almost the same as a struct here).
  • The GetOrders method returns an array of Order objects.

Using the WSDL.exe command line proxy generation tool, the marshaling of these data types is transparent to the consuming client application. A sample client application for the above XML Web service follows:

 
VB DataTypesClient.aspx

[Run Sample] | [View Source]


Copyright 2001-2002 Microsoft Corporation. All rights reserved.