locked
Is changing the namespace possible RRS feed

  • Question

  • Hi there,

    Is changing the namespace of the atom feed possible? For example in this xml snippet of a typical atom feed there are several link elements with each a rel attribute which refers to the namespace http://schemas.microsoft.com/ado/2007/08/dataservices/

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <feed xml:base="http://localhost:1365/Northwind.svc/" 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">
      <title type="text">Products</title>
      <id>http://localhost:1365/Northwind.svc/Products</id>
      <updated>2008-05-22T16:42:14Z</updated>
      <link rel="self" title="Products" href="Products" />
      <entry m:type="NorthwindModel.Products">
        <id>http://localhost:1365/Northwind.svc/Products(1)</id>
        <title type="text"></title>
        <updated>2008-05-22T16:42:14Z</updated>
        <author>
          <name />
        </author>
        <link rel="edit" title="Products" href="Products(1)" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories" type="application/atom+xml;type=entry" title="Categories" href="Products(1)/Categories" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Order_Details" type="application/atom+xml;type=feed" title="Order_Details" href="Products(1)/Order_Details" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Suppliers" type="application/atom+xml;type=entry" title="Suppliers" href="Products(1)/Suppliers" />
        <content type="application/xml">
          <m:properties>
            <d:Discontinued m:type="Edm.Boolean">false</d:Discontinued>
            <d:ProductID m:type="Edm.Int32">1</d:ProductID>
            <d:ProductName>Chai</d:ProductName>
            <d:QuantityPerUnit>10 boxes x 20 bags</d:QuantityPerUnit>
            <d:ReorderLevel m:type="Edm.Int16">10</d:ReorderLevel>
            <d:UnitPrice m:type="Edm.Decimal">18.0000</d:UnitPrice>
            <d:UnitsInStock m:type="Edm.Int16">36</d:UnitsInStock>
            <d:UnitsOnOrder m:type="Edm.Int16">0</d:UnitsOnOrder>
          </m:properties>
        </content>
      </entry>
    </feed>
    

    we would like to change the namespace url to something according to our internal style guides and get a result like this.

    <feed xml:base="http://localhost:1365/Northwind.svc/" xmlns:d="http://schemas.mycorp.com/dataservices" xmlns:m="http://schemas.mycorp.com/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
      <title type="text">Products</title>
      <id>http://localhost:1365/Northwind.svc/Products</id>
      <updated>2008-05-22T16:42:14Z</updated>
      <link rel="self" title="Products" href="Products" />
      <entry m:type="NorthwindModel.Products">
        <id>http://localhost:1365/Northwind.svc/Products(1)</id>
        <title type="text"></title>
        <updated>2008-05-22T16:42:14Z</updated>
        <author>
          <name />
        </author>
        <link rel="edit" title="Products" href="Products(1)" />
        <link rel="http://schemas.mycorp.com/dataservices/related/Categories" type="application/atom+xml;type=entry" title="Categories" href="Products(1)/Categories" />
        <link rel="http://schemas.mycorp.com/dataservices/related/Order_Details" type="application/atom+xml;type=feed" title="Order_Details" href="Products(1)/Order_Details" />
    <link rel="http://schemas.mycorp.com/dataservices/related/Suppliers" type="application/atom+xml;type=entry" title="Suppliers" href="Products(1)/Suppliers" />
    <content type="application/xml"> <m:properties> <d:Discontinued m:type="Edm.Boolean">false</d:Discontinued> <d:ProductID m:type="Edm.Int32">1</d:ProductID> <d:ProductName>Chai</d:ProductName> <d:QuantityPerUnit>10 boxes x 20 bags</d:QuantityPerUnit> <d:ReorderLevel m:type="Edm.Int16">10</d:ReorderLevel> <d:UnitPrice m:type="Edm.Decimal">18.0000</d:UnitPrice> <d:UnitsInStock m:type="Edm.Int16">36</d:UnitsInStock> <d:UnitsOnOrder m:type="Edm.Int16">0</d:UnitsOnOrder> </m:properties> </content> </entry> </feed>
    Thanks a lot,

    Ellen

    Thursday, September 10, 2009 1:32 PM

Answers

  • There is no good hook of doing this currently. If you own the service, then you could cache the response at the host layer, and do some post processing on the response and send the response back.

    Hope this helps.
    Thanks
    Pratik
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Ellen_B Wednesday, September 16, 2009 11:17 AM
    Friday, September 11, 2009 3:47 PM
    Moderator
  • Hi Ellen_B,
     As Pratik mentioned , the Data Services server doesnt have the ability to configure the Data Namespace used by the data service to generate / read ATOM payloads.
     The Client does have the ability to read from namespaces other than the server's default  , see more here:
    http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.datanamespace(VS.100).aspx

    Pablo has an example of a server-side hook as Pratik mentioned ,
    http://blogs.msdn.com/pablo/archive/2009/02/25/adding-support-for-jsonp-and-url-controlled-format-to-ado-net-data-services.aspx

    Hope this helps

    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    • Marked as answer by Ellen_B Wednesday, September 16, 2009 11:17 AM
    Friday, September 11, 2009 4:52 PM
    Moderator

All replies

  • There is no good hook of doing this currently. If you own the service, then you could cache the response at the host layer, and do some post processing on the response and send the response back.

    Hope this helps.
    Thanks
    Pratik
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Ellen_B Wednesday, September 16, 2009 11:17 AM
    Friday, September 11, 2009 3:47 PM
    Moderator
  • Hi Ellen_B,
     As Pratik mentioned , the Data Services server doesnt have the ability to configure the Data Namespace used by the data service to generate / read ATOM payloads.
     The Client does have the ability to read from namespaces other than the server's default  , see more here:
    http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.datanamespace(VS.100).aspx

    Pablo has an example of a server-side hook as Pratik mentioned ,
    http://blogs.msdn.com/pablo/archive/2009/02/25/adding-support-for-jsonp-and-url-controlled-format-to-ado-net-data-services.aspx

    Hope this helps

    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    • Marked as answer by Ellen_B Wednesday, September 16, 2009 11:17 AM
    Friday, September 11, 2009 4:52 PM
    Moderator
  • Thanks Pratik & Phani,

    I got it working following your advices. I hope in a future release of ADO.Net Data Services something like this becomes a configurable part of the SDK.

    Thanks,

    Ellen
    Wednesday, September 16, 2009 11:16 AM