C# 无法导入 wsdl:portType、wsdl:binding、wsdl:port

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18786373/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 13:12:30  来源:igfitidea点击:

Cannot import wsdl:portType, wsdl:binding, wsdl:port

c#asp.netwcfproxysvcutil.exe

提问by Pranav Singh

I am getting error while generating proxy for WCF using SVCUtil. Error is

使用 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.

Everything was working fine till I add a enum member in data contract.

一切正常,直到我在数据合同中添加一个枚举成员。

采纳答案by Pranav Singh

Turned out to be, we are reusing DataContractwhile generating proxy & old DataContract dll was not replaced in location from where it is referenced.

结果是,我们DataContract在生成代理时重用,旧的 DataContract dll 没有在引用它的位置替换。

Also get help from an response in question what-does-this-wcf-error-mean-custom-tool-warning-cannot-import-wsdlporttype?

还可以从有问题的回复中获得帮助what-does-this-wcf-error-mean-custom-tool-warning-cannot-import-wsdlporttype?

回答by spicet

Other problem could be, not passing all XSDs to svcutil. Our problem was we were using

其他问题可能是,未将所有 XSD 传递给 svcutil。我们的问题是我们正在使用

svcutil.exe service.wsdl

svcutil.exe service.wsdl

instead of

代替

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

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

FYI, we were integrating java web services to our wcf service/.net client.

仅供参考,我们正在将 Java Web 服务集成到我们的 wcf 服务/.net 客户端。