如何在C#REST服务后调用中更改元素名称

时间:2014-06-13 09:59:22

标签: c# web-services rest

我有一个REST接口方法:

[DataContract(Namespace = "")]
public class SEPTABLINE
{
    [DataMember(Order = 0)]
    public string LGNUM;
    [DataMember(Order = 1)]
    public string LABOR;
    [DataMember(Order = 2)]
    public string MATNR;
    [DataMember(Order = 3)]
    public string ACTIVE;
    [DataMember(Order = 4)]
    public string MAX_DAYS;
}

[OperationContract]
[WebInvoke(UriTemplate = "SEPTAB", Method = "POST")]
Stream AddSEPTAB(List<SEPTABLINE> separationTabLines);

要调用此方法,我必须使用以下结构:

<ArrayOfSEPTABLINE>
  <SEPTABLINE>
    <LGNUM>String content</LGNUM>
    <LABOR>String content</LABOR>
    <MATNR>String content</MATNR>
    <ACTIVE>String content</ACTIVE>
    <MAX_DAYS>String content</MAX_DAYS>
  </SEPTABLINE>
  <SEPTABLINE>
    <LGNUM>String content</LGNUM>
    <LABOR>String content</LABOR>
    <MATNR>String content</MATNR>
    <ACTIVE>String content</ACTIVE>
    <MAX_DAYS>String content</MAX_DAYS>
  </SEPTABLINE>
</ArrayOfSEPTABLINE>

如何将名称ArrayOfSEPTABLINE更改为SEPTAB? 或者是否可以将呼叫更改为

  <SEPTABLINE>
    <LGNUM>String content</LGNUM>
    <LABOR>String content</LABOR>
    <MATNR>String content</MATNR>
    <ACTIVE>String content</ACTIVE>
    <MAX_DAYS>String content</MAX_DAYS>
  </SEPTABLINE>
  <SEPTABLINE>
    <LGNUM>String content</LGNUM>
    <LABOR>String content</LABOR>
    <MATNR>String content</MATNR>
    <ACTIVE>String content</ACTIVE>
    <MAX_DAYS>String content</MAX_DAYS>
  </SEPTABLINE>

没有ArrayOfSEPTABLINE?

1 个答案:

答案 0 :(得分:0)

我不确定,但你应该试试这个

public class StreamList
{
    [DataMember]
    public List<Stream> Stream;
}

[OperationContract]
[WebInvoke(UriTemplate = "SEPTAB", Method = "POST")]
StreamList AddSEPTAB(List<SEPTABLINE> separationTabLines);