无法导入wsdl:portType、wsdl:binding、wsdl:port。

23

使用SVCUtil为WCF生成代理时,我遇到了错误。错误信息如下:

Attempting to download metadata from 'net.pipe://localhost/WebServices/Mgmt.svc' using WS-Metadata Exchange. This URL does not support DISCO.
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Referenced type 'SearchCriteria, Service.DataContracts, Version=2.5.0.0, Culture=neutral, PublicKeyToken=null
t be used since it does not match imported DataContract. Need to exclude this type from referenced types.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IMgmt']


Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IMgmt']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='NetNamedPipeBinding_IMgmt']


Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='NetNamedPipeBinding_IMgmt']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='Mgmt']/wsdl:port[@name='NetNamedPipeBinding_I


Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.

Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option.

在数据契约中添加枚举成员后,一切都正常工作。

2个回答

15

另一个问题可能是没有将所有的 XSD 文件传递给 svcutil。我们的问题在于我们使用了

svcutil.exe service.wsdl

而不是

svcutil.exe service.wsdl first.xsd second.xsd ......

顺便说一下,我们正在将 Java Web 服务集成到我们的 WCF 服务/.NET 客户端中。


2
是的,这完全是可能的。我从未想过传递 xsd 方面,因为我使用 .Net 和 WCF 分层 xsd 用于 DataContracts,这与 .net POCO 类兼容。对于增加的场景,点赞。 - Pranav Singh

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接