简体   繁体   English

将其上传到服务器主机时无法调用Web服务

[英]Can't call webservice when upload it to server host

Please to help me with problem about webservice: 请帮助我解决有关Web服务的问题:

"Server was unable to process request. ---> There was an error generating the XML document. ---> A circular reference was detected while serializing an object of type WebserviceLicenseKey.License_PaymentInfo." “服务器无法处理请求。--->生成XML文档时出错。--->序列化WebserviceLicenseKey.License_PaymentInfo类型的对象时检测到循环引用。”

When i use localhost with webservice that is good. 当我将localhost与webservice一起使用时很好。 But when i update it to server host that can't get data and raise errors as above. 但是,当我将其更新到无法获取数据并引发上述错误的服务器主机时。

This is my code in webservice, i used dbml 这是我在webservice中的代码,我使用了dbml

**[WebMethod]
        [SoapDocumentMethod(Binding = "LicenseKeyService")]
        [SoapHeader("UserAccount", Required = true)]
        public List<License_PriceDayInfo> GetAllPriceDayInfo()
        {
            if (!CheckUserAccount())
                return null;
            return _context.License_PriceDayInfos.ToList();
        }**

and in the Client call webservice and get data as: 并在客户端调用webservice并以以下方式获取数据:

  **_userCredentials.UserName = "abc";
                _userCredentials.Password = "123456";
                _licenseWs.UserCredentialsValue = _userCredentials;
               var a = _licenseWs.GetAllPaymentInfo().ToList();**

Please to help me !!! 请帮助我!

Thank you very much! 非常感谢你!

In your data contracts you probably have a property of some type, that has a property back to its parent. 在数据合同中,您可能具有某种类型的属性,该属性具有返回其父级的属性。 The serializer cannot handle this by default as it would cause a never ending serialization. 默认情况下,序列化程序无法处理此问题,因为它将导致永无止境的序列化。

To solve this, you can use flattened data contracts instead of hierarchical ones, so that you don't end up with these kind of relations (recommended), or use the IsReference property on your data contract property. 要解决此问题,可以使用扁平化的数据协定,而不要使用分层的数据协定,这样就不会以这种关系(推荐)为最终结局 ,或者在数据协定属性上使用IsReference属性。 See example here . 在这里查看示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM