Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法在Silverlight应用程序中使用WCF导入wsdl:portType、wsdl:binding、wsdl:port错误_C#_.net_Wcf_Visual Studio 2012_Silverlight 5.0 - Fatal编程技术网

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

C# 无法在Silverlight应用程序中使用WCF导入wsdl:portType、wsdl:binding、wsdl:port错误,c#,.net,wcf,visual-studio-2012,silverlight-5.0,C#,.net,Wcf,Visual Studio 2012,Silverlight 5.0,我有一个Silverlight应用程序,它通过WCF服务与服务器端的ADO.Net数据实体通信。实际上,我正在使用多个WCF服务与三个不同的数据ADO.Net数据实体进行通信。我最初在VisualStudio2010上构建了这个项目,最近在一周前转到了VisualStudioProfessional 2012(试用版)。一开始一切都很好,直到一小时前我才发现服务有问题。不到一个小时前,我在代码中使用了这些WCF服务。但是,当我添加一个方法将xml字符串插入数据库时,出现了以下错误: Conten

我有一个Silverlight应用程序,它通过WCF服务与服务器端的ADO.Net数据实体通信。实际上,我正在使用多个WCF服务与三个不同的数据ADO.Net数据实体进行通信。我最初在VisualStudio2010上构建了这个项目,最近在一周前转到了VisualStudioProfessional 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文件中可以看出它们是基本的HttpBinding。我四处寻找解决方案,发现唯一一个建议删除服务引用并在重新启动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无关,请更正

错误显示:
运行WSDL导入扩展时引发异常。这意味着,VS无法正确读取服务WSDL文件,也无法创建它需要的代理客户机类来进行服务调用

由于引用了web服务的.net应用程序将自动获取WSDL,有时它并不是它所期望的,因此这可能会造成麻烦。有一种方法可以配置如何生成WSDL文件,但并不容易()

在浏览器中的服务URL之后键入
?WSDL
query,尝试获取WSDL文件,并查看其中的内容。如果服务器位于代理服务器后面,则可能会导致问题。在WSDL文件的末尾,您将找到“绑定”、“端点”和“端口”标记/属性

根据您发布的错误消息,WSDL不符合预期的模式,解析失败


一个简单的解决方法是,如果您可以访问服务器,将生成的WSDL文件保存在服务所在的同一目录中,根据需要修改WSDL文件,并在客户端应用程序中添加对修改后的WSDL文件的引用。当然,这有一个副作用,即每次更改服务定义时文件都不同步。因此,如果您计划在将来大量更改这些方法,最好是更改/修复自动控制系统。

请向我们展示您添加的操作合同。我打赌它使用的是Silverlight不支持的.NET类型。如果您能发布一段复制代码,这将非常有用。谢谢,PraburajI我也很想看看这个问题的答案。我在试图使用asp.net asmx服务的非silverlight应用程序中看到了相同的问题。您好,抱歉,我一直觉得工作忙得不可开交,无法发布,但今晚我将尝试发布请求的OperationContract和代码。另外,自从添加服务引用时确保取消选中“高级设置”下的“在所有引用的程序集中重用类型”框以来,我还没有遇到任何问题。类型的重用似乎存在一些问题。