Note that there are some explanatory texts on larger screens.

plurals
  1. POCoerce types in different namespaces with Identical layout in C#
    text
    copied!<p>I've started writing an interface for FedEx's webservice APIs. They have 3 different APIs that I'm interested in; Rate, Ship, and Track. I am generating the service proxies with SvcUtil.exe.</p> <p>The different service endpoints are each specified by FedEx in their own WSDL files. Each service endpoint has it's own xml namespace (e.g. <a href="http://fedex.com/ws/rate/v5" rel="noreferrer">http://fedex.com/ws/rate/v5</a> and <a href="http://fedex.com/ws/ship/v5" rel="noreferrer">http://fedex.com/ws/ship/v5</a>)</p> <p>The service endpoints do use quite a few identical types such as Address, Measurements, Weight, AuthenticationDetail, ClientDetail, etc...</p> <p>And here is where the problem lies, I can provide all the WSDL files at the same time to SvcUtil.exe and normally it would coalesce any identical types into a single shared type, but since each of FedEx's services are in their own namespace, and they redeclare these types in each WSDL file under that namespace what I end up with instead is an Address, Address1, and Address2 one for each namespace.</p> <p>To solve that issue, what I do now is to run each WSDL through svcutil separately and put them each in their own .NET namespace (e.g. FedEx.Rate, FedEx.Ship, FedEx.Track). The problem with this is that now I have a distinct address type in each namespace (Fedex.Rate.Address, FedEx.Ship.Address).</p> <p>This makes it difficult to generalize the code used between the services like a GetAuthenticationDetail() factory method so I don't have to repeat that code in every place I use the different services.</p> <p>Is there any way in C# to Coerce FedEx.Rate.Address to FedEx.Ship.Address?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload