我正在构建一个RESTful服务,该请求在请求中包含xmlns属性时起作用。但是,我需要使服务能够在没有xmlns属性的情况下接受请求。WCF RESTful服务 - 如何让我的服务不需要请求中的xmlns属性?
这就是我现在的工作:
<ITEM_SEND xmlns="http://schemas.datacontract.org/2004/07/WCFInventoryService">
<TRAN_ID>9483564</TRAN_ID>
<VENDOR_PART>D336</VENDOR_PART>
</ITEM_SEND>
这是我需要接受这样的要求:
<ITEM_SEND>
<TRAN_ID>9483564</TRAN_ID>
<VENDOR_PART>D336</VENDOR_PART>
</ITEM_SEND>
这里是我的界面:
namespace WCFInventoryService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract(Namespace = "")]
public interface IInvService
{
[OperationContract]
//[WebGet(UriTemplate="/Employees",ResponseFormat=WebMessageFormat.Xml)]
//Employee[] GetEmployees();
[WebInvoke(Method = "POST",
RequestFormat = WebMessageFormat.Xml,
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "")]
ITEM_REPLY GetInventory(ITEM_SEND query);
}
public class ITEM_SEND
{
public string TRAN_ID { get; set; }
public string VENDOR_PART { get; set; }
}
}
我已经尝试通过将其设置为“”来改变我为我的请求提供的数据合同的命名空间。
[DataContract(Namespace = "")]
public class ITEM_SEND
{
public string TRAN_ID { get; set; }
public string VENDOR_PART { get; set; }
}
如果您仍然可以选择切换到JSON。没有名称空间。 –