Java Reference
In-Depth Information
How It Works
Creating Sample XML Messages
For your weather service, you can represent the temperature of a particular city and date as in the
following XML message:
<TemperatureInfo city="Houston" date="2007-12-01">
<min>5.0</min>
<max>10.0</max>
<average>8.0</average>
</TemperatureInfo>
Then, you can define the data contract for your weather service. Suppose you want to define an
operation that allows clients to query the temperatures of a particular city for multiple dates. Each
request consists of a
city
element and multiple
date
elements. You should also specify the namespace
for this request to avoid naming conflicts with other XML documents. Let's save this XML message to
request.xml
.
<GetTemperaturesRequest
<city>Houston</city>
<date>2007-12-01</date>
<date>2007-12-08</date>
<date>2007-12-15</date>
</GetTemperaturesRequest>
The response consists of multiple
TemperatureInfo
elements, each of which represents the
temperature of a particular city and date, in accordance with the requested dates. Let's save this XML
message to
response.xml
.
<GetTemperaturesResponse
<TemperatureInfo city="Houston" date="2007-12-01">
<min>5.0</min>
<max>10.0</max>
<average>8.0</average>
</TemperatureInfo>
<TemperatureInfo city="Houston" date="2007-12-08">
<min>4.0</min>
<max>13.0</max>
<average>7.0</average>
</TemperatureInfo>
<TemperatureInfo city="Houston" date="2007-12-15">
<min>10.0</min>
<max>18.0</max>
<average>15.0</average>
</TemperatureInfo>
</GetTemperaturesResponse>
Search WWH ::
Custom Search