Wcf 从ASMX web服务导入wsdl时出现WsdlImporter错误

Wcf 从ASMX web服务导入wsdl时出现WsdlImporter错误,wcf,Wcf,尝试为此生成代理代码(从ASMX web服务)时,WsdlImporter(和svcutil)报告错误。我认为WCF完全向后兼容ASMX web服务?请帮忙 下面是svcutil的输出(我使用WsdlImporter得到相同的错误) Microsoft(R)服务模型元数据工具 [微软(R)Windows(R)通信基础,版本3.0.450668] 版权所有(c)微软公司。版权所有。 警告:命名空间中的可选WSDL扩展元素“header”http://sch 未处理emas.xmlsoap.org/

尝试为此生成代理代码(从ASMX web服务)时,WsdlImporter(和svcutil)报告错误。我认为WCF完全向后兼容ASMX web服务?请帮忙

下面是svcutil的输出(我使用WsdlImporter得到相同的错误)

Microsoft(R)服务模型元数据工具 [微软(R)Windows(R)通信基础,版本3.0.450668] 版权所有(c)微软公司。版权所有。 警告:命名空间中的可选WSDL扩展元素“header”http://sch 未处理emas.xmlsoap.org/wsdl/soap/。 XPath://wsdl:definitions[@targetNamespace=]http://mycompany.com/Enterprise/WebS service/Finance/']/wsdl:binding[@name='FinanceServiceSoap']/wsdl:operation[@name= 'ProcessNonfpayment']/wsdl:fault[@name='fault'] 警告:命名空间中的可选WSDL扩展元素“header”http://sch 未处理emas.xmlsoap.org/wsdl/soap/。 XPath://wsdl:definitions[@targetNamespace=]http://mycompany.com/Enterprise/WebS service/Finance/']/wsdl:binding[@name='FinanceServiceSoap']/wsdl:operation[@name= 'ProcessRefPayment']/wsdl:fault[@name='fault'] 警告:命名空间中的可选WSDL扩展元素“header”http://sch 未处理emas.xmlsoap.org/wsdl/soap/。 XPath://wsdl:definitions[@targetNamespace=]http://mycompany.com/Enterprise/WebS service/Finance/']/wsdl:binding[@name='FinanceServiceSoap']/wsdl:operation[@name= 'SearchPayments']/wsdl:fault[@name='fault'] 警告:命名空间中的可选WSDL扩展元素“header”http://sch 未处理emas.xmlsoap.org/wsdl/soap/。 XPath://wsdl:definitions[@targetNamespace=]http://mycompany.com/Enterprise/WebS service/Finance/']/wsdl:binding[@name='FinanceServiceSoap']/wsdl:operation[@name= 'GetPayments']/wsdl:fault[@name='fault'] **错误:无法导入wsdl:绑定** 详细信息:字典中不存在给定的键。 XPath到错误源://wsdl:definitions[@targetNamespace='1]http://mycompany.com /企业/WebService/Finance/']/wsdl:binding[@name='FinanceServiceSoap12'] **错误:无法导入wsdl:port** 详细信息:导入wsdl:port依赖的wsdl:binding时出错 继续。 XPath到wsdl:binding://wsdl:definitions[@targetNamespace='1]http://mycompany.com /企业/WebService/Finance/']/wsdl:binding[@name='FinanceServiceSoap12'] XPath到错误源://wsdl:definitions[@targetNamespace='1]http://mycompany.com /企业/WebService/Finance/']/wsdl:service[@name='FinanceService']/wsdl:port [@name='FinanceServiceSoap12']
导入此wsdl时,wsdl.exe崩溃,因此肯定有什么问题。即使是.NET2.0客户端也无法使用它。您可以发布web服务的代码吗?

您并没有要求这样做,但最终它可能会对您有更多帮助

您提供的WSDL设计过度,架构不足

  • WSDL中定义的每个complexType都有一个唯一的名称空间。这是不必要的。您不需要XML命名空间来保存事务消息的定义。太多的名称空间。当我查看它时,我只看到了一个名称空间(
    http:///blahblah/Finance/
    )。你可能需要更多,但你肯定不需要那么多。大量的名称空间是wsdl.exe工具崩溃的原因之一——它根本无法处理它

  • 没有模块化。XML模式应该与WSDL分开。对于那些经过验证的名称空间,对每个名称空间使用单独的.xsd文件,并对这些架构执行xsd:import。可能是您有一个XSD文件

  • 您拥有从公共基类型派生的complexTypes,但基类型中没有。没有消息Id,没有消息版本。这似乎有点麻烦

  • 提供的WSDL不会将端口类型映射到绑定。这是wsdl.exe不会从中生成代码的原因之一。wsdl.exe在porttype中的wsdl:input元素上查找name属性,该属性必须与绑定上的wsdl:input元素上的name属性匹配

  • 你的绑定太多了。您真的需要SOAP1.1、SOAP1.2、HTTPGET和HTTPPOST吗?真正地挑一个,坚持下去

  • 现在该怎么办?

    我想你没有控制ASMX,你也没有访问代码的权限。我要做的是手动重新处理WSDL,使其有意义——将所有这些模式分离到单独的.xsd文件中。然后从WSDL的一个简单子集开始,并获取它以使其工作。反复添加更复杂的部分,直到得到所需的部分。

    您好,Darin,谢谢您的回复。不幸的是,我没有访问代码的权限。 Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.648] Copyright (c) Microsoft Corporation. All rights reserved. Warning: The optional WSDL extension element 'header' from namespace 'http://sch emas.xmlsoap.org/wsdl/soap/' was not handled. XPath: //wsdl:definitions[@targetNamespace='http://mycompany.com/Enterprise/WebS ervice/Finance/']/wsdl:binding[@name='FinanceServiceSoap']/wsdl:operation[@name= 'ProcessNonRefPayment']/wsdl:fault[@name='fault'] Warning: The optional WSDL extension element 'header' from namespace 'http://sch emas.xmlsoap.org/wsdl/soap/' was not handled. XPath: //wsdl:definitions[@targetNamespace='http://mycompany.com/Enterprise/WebS ervice/Finance/']/wsdl:binding[@name='FinanceServiceSoap']/wsdl:operation[@name= 'ProcessRefPayment']/wsdl:fault[@name='fault'] Warning: The optional WSDL extension element 'header' from namespace 'http://sch emas.xmlsoap.org/wsdl/soap/' was not handled. XPath: //wsdl:definitions[@targetNamespace='http://mycompany.com/Enterprise/WebS ervice/Finance/']/wsdl:binding[@name='FinanceServiceSoap']/wsdl:operation[@name= 'SearchPayments']/wsdl:fault[@name='fault'] Warning: The optional WSDL extension element 'header' from namespace 'http://sch emas.xmlsoap.org/wsdl/soap/' was not handled. XPath: //wsdl:definitions[@targetNamespace='http://mycompany.com/Enterprise/WebS ervice/Finance/']/wsdl:binding[@name='FinanceServiceSoap']/wsdl:operation[@name= 'GetPayments']/wsdl:fault[@name='fault'] **Error: Cannot import wsdl:binding** Detail: The given key was not present in the dictionary. XPath to Error Source: //wsdl:definitions[@targetNamespace='http://mycompany.com /Enterprise/WebService/Finance/']/wsdl:binding[@name='FinanceServiceSoap12'] **Error: Cannot import wsdl:port** Detail: There was an error importing a wsdl:binding that the wsdl:port is depend ent on. XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://mycompany.com /Enterprise/WebService/Finance/']/wsdl:binding[@name='FinanceServiceSoap12'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://mycompany.com /Enterprise/WebService/Finance/']/wsdl:service[@name='FinanceService']/wsdl:port [@name='FinanceServiceSoap12']