Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums

Go Back   Vista Forums > Vista technology newsgroups > Indigo

Serialization of DataContract with Unwrapped Array

Reply
 
Thread Tools Display Modes
Old 03-14-2008   #1
Shaun McDonnell
Guest
 
Posts: n/a

Serialization of DataContract with Unwrapped Array

I am having a problem getting a data contract to serialize correctly and I
haven't been able to come up with a solution yet.



Basically, I have the following Xml Schema that clients are sending to my
WCF Service as pure Xml:



http://docs.oasis-open.org/emergency...proved/cap.xsd



The method that my service implements looks like this:



[OperationContract(IsOneWay = true)]

[WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, RequestFormat =
WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]

void PostCapAlert(Alert message);



where 'Alert' is my DataContract that matches the aforementioned schema.
Please bear with me as I will try to provide as many details as possible
without confusing the question.



Using fiddler, I send the following xml message to the service-method above:



<alert>

<identifier>43b080713727</identifier>
<sender>hsas@xxxxxx</sender>
<sent>2003-04-02T14:39:01-05:00</sent>
<status>Actual</status>
<msgType>Alert</msgType>
<scope>Public</scope>
<info>
<category>Security</category>
<event>Homeland Security Advisory System Update</event>
<urgency>Immediate</urgency>
<severity>Severe</severity>
<certainty>Likely</certainty>
<senderName>U.S. Government, Department of Homeland Security</senderName>
<headline>Homeland Security Sets Code ORANGE</headline>
<description>The Department of Homeland Security has elevated the Homeland
Security Advisory System threat level to ORANGE / High in response to
intelligence which may indicate a heightened threat of
terrorism.</description>
<instruction>A High Condition is declared when there is a high risk of
terrorist attacks. In addition to the Protective Measures taken in the
previous Threat Conditions, Federal departments and agencies should consider
agency-specific Protective Measures in accordance with their existing
plans.</instruction>
<web>http://www.dhs.gov/dhspublic/display?theme=29</web>
- <parameter>
<valueName>HSAS</valueName>
<value>ORANGE</value>
</parameter>
- <resource>
<resourceDesc>Image file (GIF)</resourceDesc>
<uri>http://www.dhs.gov/dhspublic/getAdvisoryImage</uri>
</resource>
- <area>
<areaDesc>U.S. nationwide and interests worldwide</areaDesc>
</area>
</info>
</alert>

Almost everything gets deserialized correctly except for the unwrapped
arrays (like the 'info' element). To troubleshoot the issue I took data
from an existing instance of the 'Alert' DataContract and serialized it into
xml. The resulting xml document is this:

<alert xmlns="urnasis:names:tc:emergency:cap:1.1"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

<addresses i:nil="true" />
<code i:nil="true"
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
<identifier>43b080713727</identifier>
<incidents i:nil="true" />
- <info>
- <a:AlertInfo>
<a:area i:nil="true" />
<a:audience i:nil="true" />
<a:category i:nil="true" />
<a:certainty>Likely</a:certainty>
<a:contact>test</a:contact>
<a:description>test description</a:description>
<a:effective>0001-01-01T00:00:00</a:effective>
<a:event>lalalala</a:event>
<a:eventCode i:nil="true" />
<a:expires>0001-01-01T00:00:00</a:expires>
<a:headline i:nil="true" />
<a:instruction i:nil="true" />
<a:language>en-US</a:language>
<anSet>0001-01-01T00:00:00</anSet>
<aarameter i:nil="true" />
<a:resource i:nil="true" />
<a:responseType i:nil="true" />
<a:senderName i:nil="true" />
<a:severity>Extreme</a:severity>
<a:urgency>Immediate</a:urgency>
<a:web i:nil="true" />
</a:AlertInfo>
</info>
<msgType>Alert</msgType>
<note i:nil="true" />
<references i:nil="true" />
<restriction i:nil="true" />
<scope>Public</scope>
<sender>hsas@xxxxxx</sender>
<sent>2003-04-02T15:39:01-04:00</sent>
<source i:nil="true" />
<status>Actual</status>
</alert>

As you can see, my problem is that the 'info[]' array is being treated like
a collection and thus is being wrapped with the <info></info> tag following
by each one of the items in the array.

My question is how can make the serialization use a new <info></info> tag
for each item in the array as the previous xsd schema requires?

Thanks for your time.

-sm


  Reply With Quote

Reply

Thread Tools
Display Modes









Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Vistax64.com 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48