【问题标题】:Namespace issue in the XML payload POSTing to WCF REST servicePOST 到 WCF REST 服务的 XML 有效负载中的命名空间问题
【发布时间】:2012-02-16 17:53:38
【问题描述】:

我收到带有以下代码的 400 错误请求错误:

这是我的 WCF 服务合同

[WebInvoke(UriTemplate = "/cust_key/{key}/prod_id/{id}", 
           Method = "POST",
           BodyStyle = WebMessageBodyStyle.Bare, 
           RequestFormat = WebMessageFormat.Xml, 
           ResponseFormat = WebMessageFormat.Xml)]
Stream GetData(string key, string id, XElment data);

以下 xml 有效负载将起作用并返回 200

<Product>
  <Name>laptop</Name>
</Product>

但是下面这个带有 non-default 命名空间的 xml 将导致 400 错误

<Productxsi:type="electronics" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Name>laptop</Name>
</Product>

我应该如何处理这个命名空间问题?

【问题讨论】:

    标签: c# .net xml wcf rest


    【解决方案1】:

    事实证明这是一件愚蠢的事情:我在 xml 中转义了引用,现在它正在工作......对不起这个愚蠢的问题。希望这在某种程度上可以帮助某人。

    【讨论】:

      猜你喜欢
      • 2016-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-11
      • 1970-01-01
      • 1970-01-01
      • 2011-05-09
      相关资源
      最近更新 更多