Wcf 如何将枚举发送到REST中的某个方法?

Wcf 如何将枚举发送到REST中的某个方法?,wcf,Wcf,我需要编写一些可以使用REST调用的方法(使用“Post”)。 该方法需要获得两个参数 a-某些枚举 b-一些int 是否可以发送此枚举参数?如果是这样,我该怎么做 请查找上述场景的示例: [WebInvoke(UriTemplate = "GetEnumValues/{id}")] string GetEnumValues(MyEnum e, string id); public enum MyEnum { Fail = 0, Success = 1 } 现在,从fid

我需要编写一些可以使用REST调用的方法(使用“Post”)。 该方法需要获得两个参数 a-某些枚举 b-一些int


是否可以发送此枚举参数?如果是这样,我该怎么做

请查找上述场景的示例:

[WebInvoke(UriTemplate = "GetEnumValues/{id}")]
string GetEnumValues(MyEnum e, string id);

public enum MyEnum
{
     Fail = 0,
     Success = 1
}
现在,从fiddler执行post时,请求如下所示:

URL : http://localhost/Sample/Service1.svc/GetEnumValue/5
User-Agent: Fiddler
Content-Type: application/xml
Host: localhost

<MyEnum xmlns="http://schemas.datacontract.org/2004/07/XMLService">Success</MyEnum>
现在,您的需求如下所示:

URL:http://localhost/Sample/Service1.svc/GetEnumValuesWrapped
User-Agent: Fiddler
Content-Type: application/xml
Host: localhost

<GetEnumValuesWrapped xmlns="http://tempuri.org/"><MyEnum xmlns="http://schemas.datacontract.org/2004/07/XMLService">Success</MyEnum><int xmlns="http://schemas.microsoft.com/2003/10/Serialization/">5</int></GetEnumValuesWrapped>
URL:http://localhost/Sample/Service1.svc/GetEnumValuesWrapped
用户代理:Fiddler
内容类型:application/xml
主机:本地主机
成功5
URL:http://localhost/Sample/Service1.svc/GetEnumValuesWrapped
User-Agent: Fiddler
Content-Type: application/xml
Host: localhost

<GetEnumValuesWrapped xmlns="http://tempuri.org/"><MyEnum xmlns="http://schemas.datacontract.org/2004/07/XMLService">Success</MyEnum><int xmlns="http://schemas.microsoft.com/2003/10/Serialization/">5</int></GetEnumValuesWrapped>