SVCUtil skip complexType wsdl to avoid duplication

I have several wsdl files uploaded on my local one - A.WSDL and B.WSDL

A.WSDL has the same set of complex type (almost 100) as B.WSDL <xsd:complexType name="Book"> , but the methods / operations are different.

For example: A.WSDL has a complex type <xsd:complexType name="Book"> , and operations create new operations

B.WSDL has the same complex type <xsd:complexType name="Book"> , and read operations

I use SVCUtil to create client-side stubs in a single file and stubs with the same namespace. But getting the following error:

Error: An error occurred validating some XML schemas generated during the export: Type complex http://mylocalhost/object:Book has already been declared.

Limitations:

1) I will not be able to modify the WSDL files.

2) I would like to generate the generated stub classes in the space with the same name.

3) No wsdl.exe

Is there a way that a duplicated complexType can be skipped or can be overwritten?

0
source share
2 answers

I did this by writing a batch file.

Approach 1) Create proxy classes for A.wsdl using SVCUtil

2) Compile them into .dll files

3) Create proxy classes for B.wsdl that reference 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 `

0
source

I quote that Daniel Roth 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." 
+2
source

Source: https://habr.com/ru/post/958650/


All Articles