Tuesday, January 10, 2012

SvcUtil and imports

Recently I had to generate a client proxy for a WCF service. As the service was being developed by another team and was running as a local service on their machines, the only thing they could give me to generate my client proxy were the generated wsdl and xsd files of the service. I had no access to the actual service.

So, I started up svcutil.exe and tried to generate the client proxy. This didn't work as expected, however. Since the wsdl file generated by WCF uses imported xsd files. When you run svcutil with access to the actual service, the tool automatically downloads the necessary extra xsd files for you. When, however, you don't have access to the WCF service, you need to specify the extra xsd files in your call to svcutil.

So the following call:

SvcUtil.exe /noconfig the_wsdl_file.xml

Which gives errors on wsdl:portType and wsdl:binding, can be changed to this:

SvcUtil.exe /noconfig the_wsdl_file.xml first_import.xsd second_import.xsd

And that second call works just fine. No errors, my client proxy got nicely generated.

Another must-know about svcutil is that when you want to have your list types generated as a generic list in stead off an array type, you need to use the following extra switch:


Beware of the quote there, it's a tricky one. And you do need the entire namespace as well or svcutil won't recognize the type.


  1. Hi Gitte,

    First of all thank you for this article. It's helpful for me.

    I have a question. How to use SvcUtil.exe in case we have imports not only in main WSDL files, but in imported XSD files as well?

    Thank you in advance.


  2. Hi Goran,

    Normally, it should be able to find those. What you do need to do sometimes, is in the main wsdl alter the paths to the imported xsd files. Especially when the XSD files are located in subfolders, what I sometimes do, is copy all files to one folder (without subfolders) and alter all paths both within the wsdl file as in the xsd files (because often they reference each other as well).

    Does that solve your problem?

    Kind regards,

  3. So, I still have the same issue. If you have time you can take a look at detailed description of the problem with some files at this address:



  4. I don't think you have mentioned all of the xsd files when you perform the svcutil statement.

    Your wsdl imports xsd files, who as well import even more xsd files. You really should mention all of them. If I look at your svcutil statement, you mention 8 additional xsd files, those, I gues are the 8 that are imported in the original wsdl. But the one xsd file you have in your post imports another xsd as well. So that's at least a 9th xsd file. This one should be mentioned as well when you run svcutil. And that goes for all additional xsd files.

  5. Thank you for your kindness. Ok. I added all XSD names now. Some XSD imports are repeating in different XSD files. I suppose I don't need to repeat them in SvcUtil.exe command. If so, I added all XSD files that appear at least once in any of XSD imports, but still have the same error.