How Do I: Handle DataSets Returned from .NET Web Services?

DataSets are a data type used by .NET to store information in a format that is similar to a relational database. Each DataSet may contain a number of tables. .NET web services return DataSets by serializing them into XML.

You have two choices when deciding how to write code to accept the XML-encoded DataSet: you can write code that processes the XML DOM (Document Object Model) Node directly, or you can write an XML map that will process the incoming XML message automatically.

# Handling the DOM Node

You might choose to handle the XML DOM node directly if the structure of the DataSet is subject to change or is otherwise unpredictable. If the structure does not change, even though the quantity of data may, you should consider using the XML map approach described in the next section.

If you create a Service control for a .NET web service that returns a DataSet, the corresponding method on the Service control will return an org.w3c.Node. This class is part of the W3C Document Object Model (DOM), which is an API that may be used to manipulate XML documents directly.

To learn more about the DOM, see Document Object Model (DOM).

# Using an XML Map

If the structure of the DataSet being returned is constant, you can construct an XML map that will enable WebLogic Server to process the incoming XML automatically, converting it to Java objects of your choice. To do this:

1. Test the .NET service, capturing the returned XML-encoded DataSet.

2. Examine the structure of the XML. Since it represents query returns, it consists of a hierarchy of XML elements that match the structure of the query result.

3. Produce an XML map that matches the structure of the DataSet XML.

4. Apply this XML map as the value of a @return-xml tag on the method you are using to call the .NET service.

5. Make use of the <xm:multiple> attribute to handle repeating structures.

6. WebLogic Server will now extract the data from the incoming XML automatically and transfer it to the Java object the Service control method returns.

Related Topics

How Do I: Communicate with .NET Web Services?

Service Control: Using Another Web Service

Handling and Shaping XML Messages with XML Maps

Why Use XML Maps

<xm:multiple> Attribute

ConsolidateAddress.jws Sample

InputMapMultiple.jws Sample