SVCUtil skip complexType of a wsdl to avoid duplicates

霸气de小男生 提交于 2019-12-04 21:40:25

I quote what Daniel Roth has provided here

"I think you are looking for something like the /shareTypes feature in wsdl.exe.  
 If you want to correctly share types all you need to do is generate clients 
 for both service at the same time.  You can do this by passing the location 
 of the metadata for both services to svcutil:

       svcutil [service url1] [service url2]

 When you pass both services to svcutil at the same time svcutil can figure out 
 which types are shared and only generate one type instead of many.

 If you want svcutil to generate existing types instead of new types, you need 
 to 'reference' the existing types in a DLL:

      svcutil /reference:MyTypes.dll [service url1] [service url2]

 If there are types in the referenced DLL that you don't want to be used in code           
 generation, you can use the /excludeType switch to keep that type from getting 
 generated."

I did this by writing a batch file.

The approach was 1) Create proxy classes for A.wsdl using SVCUtil

2) Compile them to .dll files

3) Create proxy classes for B.wsdl referencing to the dll file created in #2 using SVCUtil.

Below are the lines of code:

"Your_Windows_SDK_Path\Bin\SvcUtil.exe" A.wsdl /language:C# /out:A.cs

"Your_Windows_.NetFramework_Path\csc.exe" /target:library /out:myreferences.dll A.cs

"Your_Windows_SDK_Path\Bin\SvcUtil.exe" B.wsdl /r:myreferences.dll /language:C# /out:B.cs /mergeconfig /config:output.config `

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!