2013-04-05 108 views
0

我已經下載了我的本地多個WSDL文件 - A.WSDL和B.WSDLSvcUtil工具跳過WSDL的複雜類型,以避免重複

A.WSDL具有相同的一組複雜類型(近100)爲B的.SDL <xsd:complexType name="Book">但方法/操作是不同的。

例如: A.WSDL具有複雜類型<xsd:complexType name="Book">和操作是創建新的業務

B.WSDL有相同的複雜類型<xsd:complexType name="Book">和操作被讀操作

我使用SvcUtil工具就生成存根客戶端結束到一個單一的文件並存根與相同的命名空間。但是得到以下錯誤:

錯誤:驗證導出期間生成的一些XML模式時出錯: 複雜類型http://mylocalhost/object:Book已被聲明。

約束條件是:

1)我不能夠改變的WSDL文件。

2)希望將生成的存根類放置在單個名稱空間中。

3)無Wsdl.exe用

有沒有辦法,要麼重複的複雜類型可以跳過或可能會被覆蓋?

+2

複雜類型= A類命名空間? wtf? – Nahum 2014-01-06 04:54:16

+0

@NahumLitvin:這不是兩個不同的類。兩者都是具有相同複雜類型結構的相同類,但在兩個不同的wsdls中。兩種不同的wsdls中的操作是不同的。我無法控制wslds。這是如何從第三方系統生成的 – Raghav 2014-01-06 04:56:26

+0

如果您不能更改文件創建一個小腳本,將生成一個新的文件。 沒有其他辦法解決這個問題。 – Nahum 2014-01-06 05:03:59

回答

0

我這樣做。

的方法是 1)使用SvcUtil工具

2 A.wsdl創建代理類)編譯他們的.dll文件

3)創建代理類B.wsdl引用到創建的dll文件在#2中使用SVCUtil。

下面是代碼行: 你想有兩個clases具有相同名稱在同一

"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 `

2

我引述丹尼爾羅斯已經通過編寫一個批處理文件提供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." 
+1

svcutil [服務url1] [服務url2] - 從來沒有爲我工作,因爲錯誤「complexType已被聲明」 – Raghav 2014-01-13 02:56:44

+0

我不能排除手動,因爲有100個和奇數據對象(複雜類型) – Raghav 2014-01-14 03:08:58