2009-05-27 82 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的一個簡單子集開始,並獲取它以使其可用。迭代地加回更復雜的部分,直到你有你需要的東西。