Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVCUTIL.EXE: Any way to separate my Commons.xsd classes? (C#)

Basically I have the following scenario:

I have 2 WSDL files:

  • User.wsdl
  • Customer.wsdl

Both of these wsdl's reference a Commons.xsd (Schema) so that they can use an Address ComplexType.

Then I do svcutil.exe "User.wsdl" "Commons.xsd" to generate the code for the User wsdl.
Then I do svcutil.exe "Customer.wsdl" "Commons.xsd" to generate the code for the Customer wsdl.

The problem is this: How do I get svcutil to put Address in it's own "Commons" namespace? As it stands right now, it creates an Address type in both of the output files (User.cs and Customer.cs) which cause a name collision, or if I specify a namespace now I have two Address types, each in their own namespace, which means I can't pass around the same reference between User and Customer for address (sometimes a user is also a customer, so they have identical addresses).

Is there some way of making svcutil split out the Address into its own namespace? And also, if it can put it in it's own file (Common.cs) that would rock too. But, I don't see a way for it to do so.

like image 677
michael Avatar asked Oct 27 '25 08:10

michael


1 Answers

svcutil has a /namespace argument that allows you to map wsdl namespaces to a given code namespace. You can provide this argument multiple times, but it's not well documented, so you may need to play around with it quite a bit... you can specify a wildcard, but I'm not sure if you can single out one namespace and wildcard the rest.

I'm not sure about this, but I think that if you do both wsdl's at the same time, I think they will combine into one .cs file... maybe it will be smart enough to not duplicate classes at that point.

For eg.

svcutil.exe "User.wsdl" "Customer.wsdl" "Commons.xsd"  
/n:UserAddressNamespace,User.Address  
/n:*,User

Hopefully that helpssome, I wish I could give you a better answer, but it's been a long time since I used wsdl's.

like image 106
womp Avatar answered Oct 29 '25 23:10

womp