При создании службы WCF Rest я заметил, что не все параметры в моей веб-службе
Вот интерфейс:
[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; }
}
Я передаю этот XML в:
<Appointment xmlns="http://ngs.bosley.com/BosleySchedulingService">
<ContactId>1123-123</ContactId>
<Location>Fresno</Location>
<Time>2012-05-05T08:30:00</Time>
<ResponseType>45</ResponseType>
<ServiceType>45</ServiceType>
</Appointment>
В моем сервисе я просто вывожу значения в журнал, чтобы я мог проверить, что значения поступают за это время быть:
logger.Debug("ContactId: " + appointment.ContactId);
logger.Debug("Time Field: " + appointment.Time);
logger.Debug("Location: " + appointment.Location);
logger.Debug("Response Type: " + Convert.ToInt32(appointment.ResponseType));
logger.Debug("ServiceType: " + Convert.ToInt32(appointment.ServiceType));
Однако в моем выводе целочисленные значения выглядят как нули:
ContactId: 1123-123
Time Field: 2012-05-05T08:30:00
Location: Fresno
Response Type: 0
ServiceType: 0
Когда я удаляю строки из DataContract и реализации службы, целочисленные значения проходят без проблем
Response Type: 45
ServiceType: 45
Я совершенно запутался