MiscellaneousUser
MiscellaneousUser

Reputation: 3063

Namespace being added to XML

I have a WebRequest service (External Client) that sends

<Sales>
   <Customer>
        <Name>John</Name>
   </Customer>
   <Goods>
       <Good>
          <id>5445</id>
       </Good>
       <Good>
          <id>6767</id>
       </Good>
    </Goods>
 </Sales>

But when XML is received, the Goods mysteriously has a namespace added to it.

<Good xlmns="http://example.com/INT">

My Service is :-

[OperationContract]
[WebInvoke(UriTemplate = "SendRequest", BodyStyle = WebMessageBodyStyle.Wrapped, Method = "POST", ResponseFormat = WebMessageFormat.Xml)]
public Sales(clsCustomer Customer, clsGoods Goods)

I have to remove the Xlmns.

When the XML is parsed into the parameters of the function, the Customer object is filled however the Goods object is null. When I add an extra node layer between Goods and Good and use XMLElement to accept the values, I find the node Good now has a namespace which I didn't add. Internally, Good is now <Good xlmns="http://example/Int">, how do I prevent .NET adding xmlns ?

Upvotes: 2

Views: 75

Answers (1)

John83
John83

Reputation: 143

Convert Goods to a list of strings from the list of integers first:

Goodstr = Goods.ConvertAll(delegate(int i) { return i.ToString(); });

and use that to populate the XML

Upvotes: 1

Related Questions