0

您是否需要在 iOS 中创建与 WCF 服务上的 POST 方法相同的对象?

WCF 服务中的 POST 调用示例

[OperationContract]
    [WebInvoke(Method = "POST",
       ResponseFormat = WebMessageFormat.Json,
       RequestFormat = WebMessageFormat.Json,
       BodyStyle = WebMessageBodyStyle.Wrapped,
       UriTemplate = "")]
       //method
       Employee PostEmp(Employee emp);
[DataContract]
public class Employee
{
    [DataMember]
    public string firstname { get; set; }
    [DataMember]
    public string idkey { get; set; }
    [DataMember]
    public string lastname { get; set; }
    [DataMember]
    public string salary { get; set; }

    public Employee(string first, string id, string sal, string last)
    {
        firstname = first;
        idkey = id;
        salary = sal;
        lastname = last;

    }
4

1 回答 1

0

不,您不会在 iOS 上创建那些 POCO 类。iOS 只会从 WCF 服务读取 Json 字符串响应。iOS 设备也会将 Json 发布到服务 url。

wcf 服务将为您完成所有序列化/反序列化。

于 2012-07-02T19:08:59.707 回答