簡體   English   中英

無法在Silverlight應用程序中使用WCF導入wsdl:portType,wsdl:binding,wsdl:port錯誤

[英]Cannot import wsdl:portType, wsdl:binding, wsdl:port errors with WCF in Silverlight Application

我有一個Silverlight應用程序,它通過WCF服務與服務器端的ADO.Net數據實體進行通信。 實際上,我使用多個WCF服務與三個不同的數據ADO.Net數據實體進行通信。 我最初在Visual Studio 2010上構建了這個項目,最近大約一周前轉移到了Visual Studio Professional 2012(試用版)。 最初工作/移植的一切都很好,直到大約一小時前,我對服務沒有任何問題。 不到一小時前,我在我的代碼中使用了這些相同的WCF服務。 但是,當我添加一個方法將xml字符串插入我的數據庫時,我收到此錯誤:

Content Type text/xml; charset=utf-8 was not supported by service . The client and service bindings may be mismatched.

但我檢查了綁定,從ServiceReferences.ClientConfig文件中可以看出它們是basicHttpBinding。 我四處尋找解決方案,我唯一能找到的建議是在重啟Visual Studio后刪除服務引用並讀取它,所以我終於嘗試了,但是現在,即使刪除了我添加的方法,我現在也會收到此錯誤我嘗試在客戶端上添加服務引用:

Warning 6   Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Exception has been thrown by the target of an invocation.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IXMonitorXMLDataService']    C:\Users\ckarrs\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1\Service References\XMonitorXMLDataService\Reference.svcmap  1   1   SL_xMonitor_Frontend_RefactorV1


Warning 7   Custom tool warning: 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='IXMonitorXMLDataService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_IXMonitorXMLDataService']    C:\Users\ckarrs\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1\Service References\XMonitorXMLDataService\Reference.svcmap  1   1   SL_xMonitor_Frontend_RefactorV1

Warning 8   Custom tool warning: 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='BasicHttpBinding_IXMonitorXMLDataService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='XMonitorXMLDataService']/wsdl:port[@name='BasicHttpBinding_IXMonitorXMLDataService']  C:\Users\ckarrs\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1\Service References\XMonitorXMLDataService\Reference.svcmap  1   1   SL_xMonitor_Frontend_RefactorV1

Warning 9   Custom tool warning: No endpoints compatible with Silverlight 5 were found. The generated client class will not be usable unless endpoint information is provided via the constructor.  C:\Users\ckarrs\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1\Service References\XMonitorXMLDataService\Reference.svcmap  1   1   SL_xMonitor_Frontend_RefactorV1

Warning 10  Custom tool warning: Exception has been thrown by the target of an invocation.  C:\Users\ckarrs\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1\Service References\XMonitorXMLDataService\Reference.svcmap  1   1   SL_xMonitor_Frontend_RefactorV1

我感到很困惑。 其他服務引用保持不變,並且此服務完全正常工作,直到我嘗試添加並更新引用。 這是VS 2010和2012之間的兼容性問題嗎? MSDN網站稱VS 2012向后兼容VS 2010,一切似乎都在好轉。 非常感謝任何幫助,我很困惑。 如果需要其他信息,請告訴我。

我不是WCF的專家,但我知道.net Web服務和WSDL,所以如果信息與WCF無關,請更正。

錯誤說明: An exception was thrown while running a WSDL import extension 這意味着,VS無法正確讀取服務WSDL文件,並且無法創建所需的代理客戶端類,以便進行服務調用。

因為引用Web服務的.net應用程序將自動獲取WSDL,有時它不是它所期望的,這可能會帶來麻煩。 有一種方法可以配置WSDL文件的生成方式,但是不是那么容易做到( 在這里閱讀更多

嘗試通過在瀏覽器中的服務URL之后鍵入?wsdl查詢來獲取WSDL文件,並查看其中的內容。 如果服務器位於代理服務器后面,則可能會導致問題。 在WSDL文件的末尾,您將找到“綁定”,“端點”和“端口”標記/屬性。

根據您發布的錯誤消息,WSDL不符合預期的架構,並且解析了failes。

一個簡單的解決方法是,如果您有權訪問服務器,將生成的WSDL文件保存在服務所在的同一目錄中,根據您的需要修改WSDL文件,並在您的服務器中添加對修改后的WSDL文件的引用客戶申請。 當然,這會產生副作用,即每次更改服務定義時文件都不同步。 因此,如果您計划在將來更改方法,可能更好的方法是更改​​/修復自動WSDL生成

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM