Question

I have multiple wsdl files downloaded on my local - A.WSDL and B.WSDL

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

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

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

I am using SVCUtil to generate stubs on the client end to a single file and stubs with the same namespace. But getting the below error:

Error: There was an error verifying some XML Schemas generated during export: The complexType http://mylocalhost/object:Book has already been declared.

The constraints are:

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

2) Would like to place the generated stub classes in single name space.

3) No wsdl.exe

Is there any way that either the duplicated complexType could be skipped or could be overwritten?

Was it helpful?

Solution 2

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 `

OTHER TIPS

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."
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top