我觉得这是一个愚蠢的问题,甚至在提问之前,但我的大脑现在工作得不好。我有两个WCF服务“CountryService”和“FloristService”。

现在CountryService有以下方法:

IList<CountryDTO> GetAllCountries();

此外,FloristService有一个方法:

bool AddFlorist(FloristDTO florist);

到目前为止一切都很好,但问题是FloristDTO引用了CountryDTO,即

    public  string Address1 { get; set; }
    public  string Address2 { get; set; }
    public  string Address3 { get; set; }
    public  string City { get; set; }
    public  string Postcode { get; set; }
    public  CountryDTO Country { get; set; }
    public  string Name { get; set; }

这很好,但如果我使用服务代理生成与Visual Stuidos的工具(即添加参考&gt;添加服务参考),那么我得到两个版本的CountryDTO被创建ieFloristService.CountryDTO和CountryService.CountryDTO。

现在我可以想出几种方法来克服这个问题,但是他们看起来并不正确。我想知道“正确”是什么方法就是,我可以用代理生成工具做些什么来让它共享常见的DTO吗?

干杯,克里斯

其他提示

文章&quot;如何在服务端点之间重用类型“建议在客户端手动更新Reference.svcmap以包含多个和NamespaceMappings。

或者,svcutil允许您一次指定多个端点并使用/ r(/ reference)和/ n(/ namespace)参数。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top