【问题标题】:Pass Serialized object to WCF method, when object class has attribute [Serializable]当对象类具有属性 [Serializable] 时,将序列化对象传递给 WCF 方法
【发布时间】:2015-08-21 06:06:06
【问题描述】:

我的问题是我想将带有序列化对象的发布请求发送到 WCF 方法 这是我的代码。

[Serializable]
public class StandardCardModel
{
    public string lang { get; set; }
    public string app_source { get; set; }
    public string card { get; set; }
}

[ServiceContract]
public interface IService1
{
    [OperationContract]
    [WebInvoke(Method = "POST",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "GetLastTransactions")]
    LastTransactionsResult GetLastTransactions(StandardCardModel scm);

现在我想用参数调用“GetLastTransactions”:

{
 "lang": "en",
 "app_source": "TestSource",
 "card": "1111"
}

明确地说,我不想发送带有参数名称的 JSON 作为对象。例如:

{"scm":{....}}

我在 scm 中得到空值。有什么建议?谢谢

【问题讨论】:

标签: c# json wcf serialization


【解决方案1】:

删除BodyStyle = WebMessageBodyStyle.Wrapped。使用BodyStyle = WebMessageBodyStyle.Wrapped必须包装请求。

【讨论】:

  • 不,这不是解决方案。谢谢
  • 为我尝试 SOAP UI 或 Fiddler.Works
猜你喜欢
  • 2015-08-18
  • 2017-06-21
  • 1970-01-01
  • 2011-06-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多