I have a similar problem as this question. I have multiple web services that I am consuming with WCF, which all share types. The services themselves are written in Java and I do not have access to them. The shared types have the same signatures, but svcutil.exe
gives this error when running:
Error: There was a validation error on a schema generated during export:
Source:
Line: 8 Column: 3
Validation Error: The complexType 'http://MyServer.MyService:CommonType' has already been declared.
With CommonType
having the same signature in both web services being consumed. Here's how I'm calling svcutil
:
svcutil.exe /o:GeneratedServices.cs /n:*,MyNamespace.Generated http://MyServer.MyService1?WSDL http://MyServer.MyService2?WSDL
I know that wsdl.exe
has /mergeTypes
flag, which works for these services, but there are some options on svcutil.exe
that I'd really like to use. I did have someone demonstrate that it is possible to me, however the backend was also using .NET and WCF, and I've been unsuccessful with the Java backend I'm using.
First - are they exactly the same? In particular, the SOAP namespaces must match (in addition to everything else). If they don't, then they are different (incompatible) types; you will have to use 2 different references (in different C# namespaces to avoid conflicts), and shift data between the two types.
If the types are the same and it still doesn't work, then you can perhaps use the /r switch with svcutil to consume the types from an existing assembly. Try using it once to get the first types (just from 1 of the urls) - then compile that code into an assembly. Use svcutil against the second endpoint with the /r flag identifying the assembly you generated moments ago.
Note; a related topic is to write a partial class
for one-or-more of the types - for example, to provide conversion methods/operators on the types themselves. This might make things simpler. For example, you could write an implicit (or explicit) static conversion operator between two similar types in different namespaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With