调用Web服务以使用Windows Phone时出错

时间:2012-06-02 13:23:22

标签: silverlight web-services windows-phone-7

我在Windows 7和Visual Studio .NET 2010中使用Silverlight 5 Framework。

我正在使用 YouTube 的视频教程,了解如何使用网络服务创建Windows手机应用程序。

问题在于,当我添加Web服务“http://msrmaps.com/TerraService2.asmx”时,一旦添加了服务引用,我会收到很多错误,而且我不明白。

我按如下方式调用Web服务:

  1. 在解决方案资源管理器中,右键单击并选择“添加服务引用”
  2. 将上面的网址粘贴到地址栏
  3. 点击开始
  4. 接受提供的命名空间或键入命名空间的另一个有效名称。在我的案例中,我将其命名为TerraService。
  5. 构建项目。
  6. 警告和错误

    Warning 1   Custom tool warning: Cannot import wsdl:portType
    Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
    Error: Could not load type 'System.Runtime.Serialization.DataContractSet' from assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
    XPath to Error Source: //wsdl:definitions[@targetNamespace='http://msrmaps.com/']/wsdl:portType[@name='TerraServiceSoap']   c:\users\botoeo\documents\visual studio 2010\Projects\OpenEye\OpenEye\Service References\TerraService\Reference.svcmap
    
    Warning 2   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://msrmaps.com/']/wsdl:portType[@name='TerraServiceSoap']
    XPath to Error Source: //wsdl:definitions[@targetNamespace='http://msrmaps.com/']/wsdl:binding[@name='TerraServiceSoap']    c:\users\botoeo\documents\visual studio 2010\Projects\OpenEye\OpenEye\Service References\TerraService\Reference.svcmap
    
    Warning 3   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://msrmaps.com/']/wsdl:binding[@name='TerraServiceSoap']
    XPath to Error Source: //wsdl:definitions[@targetNamespace='http://msrmaps.com/']/wsdl:service[@name='TerraService']/wsdl:port[@name='TerraServiceSoap']    c:\users\botoeo\documents\visual studio 2010\Projects\OpenEye\OpenEye\Service References\TerraService\Reference.svcmap
    
    Warning 4   Custom tool warning: No endpoints compatible with Silverlight 3 were found. The generated client class will not be usable unless endpoint information is provided via the constructor.  c:\users\botoeo\documents\visual studio 2010\Projects\OpenEye\OpenEye\Service References\TerraService\Reference.svcmap
    
    Warning 5   Custom tool warning: Exception has been thrown by the target of an invocation.  c:\users\botoeo\documents\visual studio 2010\Projects\OpenEye\OpenEye\Service References\TerraService\Reference.svcmap
    
    Error   6   Custom tool error: Failed to generate code for the service reference 'TerraService'.  Please check other error and warning messages for details.    c:\users\botoeo\documents\visual studio 2010\Projects\OpenEye\OpenEye\Service References\TerraService\Reference.svcmap
    

    如何摆脱这些警告和错误。是什么原因造成的?

1 个答案:

答案 0 :(得分:1)

我找到了解决此问题的方法..我只是将Windows Phone SDK更新到最新版本。可以找到最新版本HERE 。下载最新的更新安装程序。保存解决方案并关闭Visual Studio。使用下载的文件更新Windows Phone SDK。一旦完成。再次打开Visual Studio。它会顺利运作。