简体   繁体   English

无法在Silverlight应用程序中使用WCF导入wsdl:portType,wsdl:binding,wsdl:port错误

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

I have a Silverlight application that is communicating with ADO.Net data entities on the server side through a WCF Service. 我有一个Silverlight应用程序,它通过WCF服务与服务器端的ADO.Net数据实体进行通信。 Actually, I am using multiple WCF services to communicate with three different data ADO.Net data entities. 实际上,我使用多个WCF服务与三个不同的数据ADO.Net数据实体进行通信。 I had originally constructed this project on Visual Studio 2010, and recently moved to Visual Studio Professional 2012 (trial version) about a week ago. 我最初在Visual Studio 2010上构建了这个项目,最近大约一周前转移到了Visual Studio Professional 2012(试用版)。 Everything worked/ported fine initially and I had no issues with the services about until about an hour ago. 最初工作/移植的一切都很好,直到大约一小时前,我对服务没有任何问题。 I was literally using these same WCF services in my code less then an hour ago. 不到一小时前,我在我的代码中使用了这些相同的WCF服务。 However, when I added a method to insert an xml string into my data base I got this error: 但是,当我添加一个方法将xml字符串插入我的数据库时,我收到此错误:

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

But I checked the bindings and they were basicHttpBinding as far as I could tell from the ServiceReferences.ClientConfig file. 但我检查了绑定,从ServiceReferences.ClientConfig文件中可以看出它们是basicHttpBinding。 I looked around for a solution and the only one I could find suggested deleting the service reference and reading it after restarting Visual Studio, so I finally tried that, but now, even after removing the method I had added, I now get this error when I try to add a service reference on the Client: 我四处寻找解决方案,我唯一能找到的建议是在重启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

I am so confused. 我感到很困惑。 The other service references remain the same, and this service was working completely until I tried to add to it and update the reference. 其他服务引用保持不变,并且此服务完全正常工作,直到我尝试添加并更新引用。 Is this a compatibility issue between VS 2010 and 2012? 这是VS 2010和2012之间的兼容性问题吗? The MSDN website says VS 2012 is backwards compatible with VS 2010 and everything seemed to migrate fine. MSDN网站称VS 2012向后兼容VS 2010,一切似乎都在好转。 Any help is greatly appreciated, I am perplexed. 非常感谢任何帮助,我很困惑。 Please let me know if additional info is required. 如果需要其他信息,请告诉我。

I am not an expert on WCF, but i know about .net web services and WSDL, so please correct if the information is not relevant to WCF. 我不是WCF的专家,但我知道.net Web服务和WSDL,所以如果信息与WCF无关,请更正。

The error says: An exception was thrown while running a WSDL import extension . 错误说明: An exception was thrown while running a WSDL import extension This means, that VS was not able to read the service WSDL file properly, and was not able to create the proxy client class it needs, in order to make the service calls. 这意味着,VS无法正确读取服务WSDL文件,并且无法创建所需的代理客户端类,以便进行服务调用。

Because an .net application with a reference to a web service will automatically get the WSDL, and sometimes it is not what it expects, this can cause trouble. 因为引用Web服务的.net应用程序将自动获取WSDL,有时它不是它所期望的,这可能会带来麻烦。 there is a way to configure how the WSDL file is generated, but is is not so easy to do ( read more here ) 有一种方法可以配置WSDL文件的生成方式,但是不是那么容易做到( 在这里阅读更多

try to get the WSDL file by typing ?wsdl query after the service URL in a browser and see what is inside. 尝试通过在浏览器中的服务URL之后键入?wsdl查询来获取WSDL文件,并查看其中的内容。 If the server is behind a proxy server, this can cause problems. 如果服务器位于代理服务器后面,则可能会导致问题。 At the end of the WSDL file you will find the 'binding', 'endpoint', and 'port' tags/attributes. 在WSDL文件的末尾,您将找到“绑定”,“端点”和“端口”标记/属性。

According to the error message you have posted, the WSDL is not according to the expected schema, and parsing failes. 根据您发布的错误消息,WSDL不符合预期的架构,并且解析了failes。

An easy workaround is, if you have access to the server, to save the generated WSDL file in the same directory, where the service is, modify the WSDL file according to what you need, and add a reference to the modified WSDL file in your client application. 一个简单的解决方法是,如果您有权访问服务器,将生成的WSDL文件保存在服务所在的同一目录中,根据您的需要修改WSDL文件,并在您的服务器中添加对修改后的WSDL文件的引用客户申请。 Of course this has a side-effect that the file is out of sync each time you change the service definition. 当然,这会产生副作用,即每次更改服务定义时文件都不同步。 so if you plan to change the methods a lot in future, maybe better is to alter/Fix the automatic WSDL generation . 因此,如果您计划在将来更改方法,可能更好的方法是更改​​/修复自动WSDL生成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM