简体   繁体   English

无法从http:// localhost:55408 / ShopProcessService.svc获取元数据

[英]Cannot obtain Metadata from http://localhost:55408/ShopProcessService.svc

I am getting the following error when trying to launch the WCF Test client for a service and is driving me crazy. 尝试启动WCF测试客户端以获取服务时出现以下错误,并使我发疯。 I have searched the web and sounds like the DataContract Name of HeaderRecord exists twice in my project. 我已经在网上搜索过,听起来像HeaderRecord的DataContract Name在我的项目中存在两次。

However, as doing a "find all" on this name only turned up one instance. 但是,对这个名称执行“查找全部”操作仅能发现一个实例。

Can somebody please help me with this error. 有人可以帮我解决这个错误。 I'm at my wits end... 我机智...

DataContract for type 'Ryder.Enterprise.DataTransferObjects.HeaderRecord[]' cannot be added to DataContractSet since type 'System.Collections.Generic.List`1[[Ryder.Enterprise.DataTransferObjects.HeaderRecord, Ryder.Enterprise.DataTransferObjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with the same data contract name 'ArrayOfHeaderRecord' in namespace 'http://www.ABC.com/SOA/DataContracts/2014/02/17' is already present and the contracts are not equivalent.

There is also no instance in my project of a name called ArrayOfHeaderRecord . 我的项目中也没有名称为ArrayOfHeaderRecord

EDIT 1 编辑1

Just for giggles, I decided to remove the Operation and Service Contract for this particular call into the method, and the WCF Test client came up successfully. 只是为了咯咯地笑,我决定删除此方法中对此特定调用的“操作和服务合同”,WCF测试客户端成功启动。 When I put the contracts back in, that's when I get the error, but I still don't know why??? 当我放回合同时,就是我得到错误的时候,但是我仍然不知道为什么?

I even went back to an old version of my source code for this method (when it was coming up in the WCF Test client) and that failed as well. 我什至回到了此方法的源代码的旧版本(在WCF测试客户端中出现该方法时),该方法也失败了。

I rebooted my machine and same thing is occurring. 我重启了机器,发生了同样的事情。 I don't understand this error. 我不明白这个错误。 Even if I put back the contracts and just have a "shell" of my class that it's calling, I get the same error. 即使我放回合同,并且只拥有要调用的类的“外壳”,我也会遇到相同的错误。

I don't know what to do anymore??? 我不知道该怎么办了???

EDIT 2 - Resolution 编辑2-解析度

After tracing down everything in my solution, I found what the error was... My class was listed as follows: Notice the implementing of the List object which should not be there. 跟踪解决方案中的所有内容之后,我发现了错误所在……我的班级列出如下:请注意List对象的实现,该对象不应该存在。

public class HeaderRecordCollection : List<HeaderRecord>
    {
        private List<HeaderRecord> headerRecords;



        public HeaderRecordCollection()
        {
        }


        [DataMember(Name = "HeaderRecords")]
        public List<HeaderRecord> HeaderRecords
        {
            get
            {
                return headerRecords;
            }
            set
            {
                headerRecords = value;
            }
        }
    }

I simply removed that where I only have one list. 我只是删除了只有一个列表的那个位置。 Since now only having one list for the object, no complaints from WCF! 从现在开始,只有一个对象清单,因此WCF没有任何投诉!

Two years late, but hey ;) 迟了两年,但是嘿;)

Substitute Attribute DataContract for CollectionDataContract 将属性DataContract替换为CollectionDataContract

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

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