dotnet / dotnet/wcf

Sharing Data Contracts

Open
#5,632 1 comment 0 reactions 1 assignee Claimed by @imcarolwang View on GitHub
tooling
Dominant language
C#
Stars
1.8k
Forks
576
Avg merge
6d 9h
Merged PRs (30d)
2

Description

**Describe the bug**
My application has 8 Services, so I am running dotnet-svcutil on each service to generate a separate service reference for each with a unique namespace for each. The problem occurs when I consume multiple services in the same client, and reference a data contract that is shared among two or more of the consumed service. In the consuming client, I see a bunch of "'DataContractModel' is an ambiguous reference between 'WS_1_WebServiceNS.Data.DataContractModel' and 'WS_2_WebServiceNS.Data.DataContractModel'". Before conversion, I used this command: "svcutil.exe" ..\My.Service.Contracts.dll /directory:..\..\..\..\deployment to generate a unified wsdl and xsd for shared Data Contracts, and then "svcutil.exe" ..\deployment\*.wsdl ..\deployment\*.xsd /language:C# /n:http://tempuri.com/MyService/2016/05,WebServiceClient /n:http://tempuri.com/MyServiceData/2016/05,WebServiceClient.Data /o:..\My.Service.Client\MyWebSvcClientApiAuto.cs /config:..\My.Service.Client\App.config

**Expected behavior**
A method to either generate service references with a shared data component, or an ability to output a generated client class which avoids the namespace collisions.

Am I missing something? The only workaround I can come up with is to somehow merge the 8 wsdl documents, but using the old wsdl tool, won't generate a dotnet Core valid wsdl document.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.