Not even sure if I'm asking the right question, but here it goes. Basically because of a lack of support of the WCF DS client for "OData deep inserts" I'm having to manually build up an Atom request. I have the request nearly complete, the only thing that is missing (and it causing a problem on the request to the server) is add the namespace prefix to the "entry" node in the XML request.
I'm using a SyndicationItem to build the request up. I need to prefix the "entry" node with "atom:" for the server to accept the request...
Any help is much appreciated. Here is the request that is being generated now:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<atom:id>uuid:8ed93950-9c16-4923-b6cc-ca5c7d020709;id=1</atom:id>
<atom:title type="text"></atom:title>
<atom:updated>2011-11-03T23:02:40Z</atom:updated>
<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/SalesOrderItems" type="application/atom+xml;type=feed" title="SALES_ORDER.SalesOrderHeader_SalesOrderItemsx" href="SalesOrderHeaders()/SalesOrderItems">
<m:inline>
<atom:feed>
<atom:entry>
<atom:content>
<m:properties>
<d:Item>10</d:Item>
<d:Material>70000559</d:Material>
<d:Plant>570B</d:Plant>
<d:Quantity>10</d:Quantity>
</m:properties>
</atom:content>
</atom:entry>
<atom:entry>
<atom:content>
<m:properties>
<d:Item>20</d:Item>
<d:Material>70000559</d:Material>
<d:Plant>570B</d:Plant>
<d:Quantity>10</d:Quantity>
</m:properties>
</atom:content>
</atom:entry>
</atom:feed>
</m:inline>
</atom:link>
<atom:content type="text/xml">
<m:properties>
<d:DocumentType>ZCSH</d:DocumentType>
<d:CustomerId>0001008657</d:CustomerId>
<d:SalesOrg>1100</d:SalesOrg>
<d:DistChannel>10</d:DistChannel>
<d:Division>40</d:Division>
</m:properties>
</atom:content>
</entry>
And here is the code I have right now to generate the request. This is just a proof of concept, so please ignore the crap. :)
XNamespace nsAtom = "http://www.w3.org/2005/Atom";
XNamespace nsD = "http://schemas.microsoft.com/ado/2007/08/dataservices";
XNamespace nsM = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
SyndicationItem soHeader = new SyndicationItem();
soHeader.AttributeExtensions.Add(new XmlQualifiedName("atom", XNamespace.Xmlns.ToString()), nsAtom.NamespaceName);
soHeader.AttributeExtensions.Add(new XmlQualifiedName("d", XNamespace.Xmlns.ToString()), nsD.NamespaceName);
soHeader.AttributeExtensions.Add(new XmlQualifiedName("m", XNamespace.Xmlns.ToString()), nsM.NamespaceName);
soHeader.Content = SyndicationContent.CreateXmlContent(
new XElement(nsM + "properties",
new XElement(nsD + "DocumentType", "ZCSH"),
new XElement(nsD + "CustomerId", "0001008657"),
new XElement(nsD + "SalesOrg", "1100"),
new XElement(nsD + "DistChannel", "10"),
new XElement(nsD + "Division", "40")
)
);
SyndicationLink link = SyndicationLink.CreateAlternateLink(new Uri("SalesOrderHeaders()/SalesOrderItems", UriKind.Relative), "application/atom+xml;type=feed");
link.Title = "SALES_ORDER.SalesOrderHeader_SalesOrderItems";
link.RelationshipType = "http://schemas.microsoft.com/ado/2007/08/dataservices/related/SalesOrderItems";
soHeader.Links.Add(link);
XElement items = new XElement(nsM + "inline",
new XElement(nsAtom + "feed")
);
for (int i = 0; i < 2; i++)
{
items.Element(nsAtom + "feed").Add(new XElement(nsAtom + "entry",
new XElement(nsAtom + "content",
new XElement(nsM + "properties",
new XElement(nsD + "Item", ((i+1)*10).ToString()),
new XElement(nsD + "Material", "70000559"),
new XElement(nsD + "Plant", "570B"),
new XElement(nsD + "Quantity", (Decimal)10.0)
)
)
)
);
}
link.ElementExtensions.Add(items);
XmlWriter xml = XmlWriter.Create("C:\\test.xml");
soHeader.SaveAsAtom10(xml);
xml.Close();