小编Rya*_*ell的帖子

并非WCF数据合同中的所有参数都通过Web服务调用

在创建WCF Rest服务时,我注意到我的Web服务中的所有参数都没有进入我的实现.

这是界面:

[ServiceContract(Namespace="http://example.com/recordservice")]
public interface IBosleySchedulingServiceImpl
{
    [OperationContract]
    [WebInvoke(UriTemplate = "Record/Create",
        RequestFormat = WebMessageFormat.Xml, 
        ResponseFormat = WebMessageFormat.Xml,
        BodyStyle = WebMessageBodyStyle.Bare, Method = "POST")]
    string CreateRecord(Record record);
}

[DataContract(Namespace="http://example.com/recordservice")]
public class Appointment
{
    [DataMember]
    public int ResponseType { get; set; }

    [DataMember]
    public int ServiceType { get; set; }

    [DataMember]
    public string ContactId { get; set; }

    [DataMember]
    public string Location { get; set; }

    [DataMember]
    public string Time { get; set; }        
}
Run Code Online (Sandbox Code Playgroud)

我正在传递这个XML:

<Appointment xmlns="http://ngs.bosley.com/BosleySchedulingService">
  <ContactId>1123-123</ContactId>
  <Location>Fresno</Location>
  <Time>2012-05-05T08:30:00</Time> …
Run Code Online (Sandbox Code Playgroud)

c# xml rest wcf

8
推荐指数
1
解决办法
4970
查看次数

标签 统计

c# ×1

rest ×1

wcf ×1

xml ×1