[英]Can't call webservice when upload it to server host
請幫助我解決有關Web服務的問題:
“服務器無法處理請求。--->生成XML文檔時出錯。--->序列化WebserviceLicenseKey.License_PaymentInfo類型的對象時檢測到循環引用。”
當我將localhost與webservice一起使用時很好。 但是,當我將其更新到無法獲取數據並引發上述錯誤的服務器主機時。
這是我在webservice中的代碼,我使用了dbml
**[WebMethod]
[SoapDocumentMethod(Binding = "LicenseKeyService")]
[SoapHeader("UserAccount", Required = true)]
public List<License_PriceDayInfo> GetAllPriceDayInfo()
{
if (!CheckUserAccount())
return null;
return _context.License_PriceDayInfos.ToList();
}**
並在客戶端調用webservice並以以下方式獲取數據:
**_userCredentials.UserName = "abc";
_userCredentials.Password = "123456";
_licenseWs.UserCredentialsValue = _userCredentials;
var a = _licenseWs.GetAllPaymentInfo().ToList();**
請幫助我!
非常感謝你!
在數據合同中,您可能具有某種類型的屬性,該屬性具有返回其父級的屬性。 默認情況下,序列化程序無法處理此問題,因為它將導致永無止境的序列化。
要解決此問題,可以使用扁平化的數據協定,而不要使用分層的數據協定,這樣就不會以這種關系(推薦)為最終結局 ,或者在數據協定屬性上使用IsReference屬性。 在這里查看示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.