2013-04-05 103 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