2009-05-27 33 views
1

当试图为此wsdl file(来自ASMX Web服务)生成代理代码时,WsdlImporter(和svcutil)报告错误。我认为WCF完全向后兼容ASMX网络服务?请帮助WsdlImporter从ASMX Web服务中导入wsdl时出错

下面是SvcUtil工具的输出(我得到使用WsdlImporter同样的错误)导入此WSDL时

 
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'] 

回答

0

Wsdl.exe用崩溃,所以必须有东西真的错了。即使是.NET 2.0客户端也无法使用它。你能发布Web服务的代码吗?

+0

嗨达林谢谢你的回应。不幸的是,我无法访问代码。 – user20155 2009-05-27 09:23:08

3

你没问这个,但它可以帮助你更加到底....

您所提供的WSDL是过度设计和欠架构。

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

  2. 没有模块化。 XML模式应该与WSDL分开。对于那些合理的名称空间,为每个名称空间分别使用一个.xsd文件,然后为这些模式执行xsd:import。它可能是你有一个单一的XSD文件。

  3. 您已经从常见的基本类型派生出complexTypes,但基本类型中没有。没有消息标识,没有消息版本。这似乎很麻烦。

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

  5. 你有太多的绑定。你真的需要SOAP1.1,SOAP1.2,HTTPGET和HTTPPOST吗?真?挑一个并坚持下去。

现在该怎么办?
我不想控制ASMX,而且您无法访问代码。我要做的就是手动重新处理WSDL,这样才有意义 - 将所有这些模式分离为单独的.xsd文件。然后从WSDL的一个简单子集开始,并获取它以使其可用。迭代地加回更复杂的部分,直到你有你需要的东西。