我正在实现一个 wcf restful 服务,我想将一个包含类列表的 xml 发送到 wcf 服务。其他参数成功传递给服务,但列表为空。我的xml;
<phoneBookWebServiceSearchResponse xmlns="http://callturksvc.alfion.com.tr">
<uniqueId>40</uniqueId>
<webServiceResponseType>SUCCESS</webServiceResponseType>
<clientQueryNo>0</clientQueryNo>
<responseMessage>SUCCESS</responseMessage>
<phoneBookList>
<phoneBook>
<cityCode>34</cityCode>
<cityName>İstanbul</cityName>
<districtName>Beşiktaş</districtName>
<firstName>Şuayp</firstName>
<lastModifiedDateTime>2013-01-28T15:30:36.925+02:00</lastModifiedDateTime>
<lastName>Çiçek</lastName>
<phoneBookTypeEnumValue>TURKCELL</phoneBookTypeEnumValue>
<phoneNumberText>5356875946</phoneNumberText>
</phoneBook>
</phoneBookList>
</phoneBookWebServiceSearchResponse>
以及将处理此 xml 的类;
[DataContract(Name = "phoneBookWebServiceSearchResponse", Namespace ="http://callturksvc.alfion.com.tr")]
public class phoneBookWebServiceSearchResponse
{
[DataMember(Order = 1, Name = "uniqueId")]
public string uniqueId { get; set; }
[DataMember(Order = 2, Name = "webServiceResponseType")]
public string webServiceResponseType { get; set; }
[DataMember(Order = 3, Name = "clientQueryNo")]
public string clientQueryNo { get; set; }
[DataMember(Order = 4, Name = "responseMessage")]
public string responseMessage { get; set; }
[DataMember(Order = 5, Name = "phoneBookList")]
public phoneBookList phoneBookList { get; set; }
public phoneBookWebServiceSearchResponse()
{
uniqueId = string.Empty;
webServiceResponseType = string.Empty;
clientQueryNo = string.Empty;
responseMessage = string.Empty;
phoneBookList = new phoneBookList();
}
}
public class phoneBookList
{
[DataMember(Order = 1, Name = "phoneBook")]
public List<phoneBook> phoneBook { get; set; }
public phoneBookList()
{
phoneBook = new List<phoneBook>();
}
}
public class phoneBook
{
[DataMember(Order = 1, Name = "firstName")]
public string firstName { get; set; }
[DataMember(Order = 2, Name = "lastName")]
public string lastName { get; set; }
[DataMember(Order = 3, Name = "cityCode")]
public string cityCode { get; set; }
[DataMember(Order = 4, Name = "cityName")]
public string cityName { get; set; }
[DataMember(Order = 5, Name = "districtName")]
public string districtName { get; set; }
[DataMember(Order = 6, Name = "lastModifiedDateTime")]
public string lastModifiedDateTime { get; set; }
[DataMember(Order = 7, Name = "phoneBookTypeEnumValue")]
public string phoneBookTypeEnumValue { get; set; }
[DataMember(Order = 8, Name = "phoneNumberText")]
public string phoneNumberText { get; set; }
public phoneBook()
{
firstName = string.Empty;
lastName = string.Empty;
cityCode = string.Empty;
cityName = string.Empty;
districtName = string.Empty;
lastModifiedDateTime = string.Empty;
phoneBookTypeEnumValue = string.Empty;
phoneNumberText = string.Empty;
}
}
响应类是;
[DataContract(Name="CallTurkResponse", Namespace ="http://callturksvc.alfion.com.tr")]
public class CallTurkResponse
{
[DataMember(Name="responseMessage", Order=1)]
public string responseMessage { get; set; }
}
我的服务等级是;
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "auth")]
CallTurkResponse Auth(phoneBookWebServiceSearchResponse res);
最后我的服务是;
public CallTurkResponse Auth(phoneBookWebServiceSearchResponse res)
{
return new CallTurkResponse
{
responseMessage = "SUCCESS"
};
}
问题是当我在上面发送 xml 请求时,我在调试器中成功获得了 uniqueId、webServiceResponseType、clientQueryNo 和 responseMessage。但是 phoneBookList 提供服务是空的。
有什么解决办法吗?