c# - 在 Windows 8 商店 C# 应用程序 : The base class or interface could not be resolved 中使用 WSDL Web 服务

标签 c# wsdl windows-store-apps

我在 Eclipse 中使用 Java 编写了一个简单的 WSDL 网络服务。以下是该服务的 Java 代码原型(prototype):

public static String vriteAnnouncement(String title, String body){
    ...
}

我已经使用 Microsoft wsdl.exe 工具为此 WSDL 服务生成了一个代理类,并通过使用来自 Developer Command Prompt Visual Studio 2012 的以下命令将其变成一个 dll:

wsdl /l:CS /protocol:SOAP WriteAnnouncement.wsdl
csc /t:library /r:System.Web.Services.dll /r:System.Xml.dll WriteAnnouncementService.cs

在我的 Windows 8 应用商店应用程序中,我添加了对此 dll 的引用,然后在 MainPage.xaml.cs 中添加了以下代码:

WriteAnnouncementService was = new WriteAnnouncementService();

当我尝试运行该应用程序时,出现此错误:

The type 'System.Web.Services.Protocols.SoapHttpClientProtocol' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
C:\Users...\MainPage.xaml.cs Line 27 Column 13

然后我添加了对 System.Web.Service 的引用并重建了应用程序。现在我收到以下错误:

The base class or interface 'System.ComponentModel.Component' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' referenced by type 'System.Web.Services.Protocols.WebClientProtocol' could not be resolved c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Web.Services.dll

最佳答案

使用 wsdl.exe 生成代理是否有原因?

我不是 bcl 的 Windows 8 商店子集的专家,但我建议使用 svcutil 从已知的 wsdl 生成代理,因为生成的代理支持较新的 Web 服务子系统。生成的代理继承自基类库中的不同类。对我来说,较新的子系统更有可能在受限环境中无缝工作。

关于c# - 在 Windows 8 商店 C# 应用程序 : The base class or interface could not be resolved 中使用 WSDL Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14163149/

相关文章:

web-services - Axis 生成所有类但不生成 Axis2?

集成到 ASP Classic 应用程序中的 C# API 例程?

c# - Windows 应用商店应用程序中的页面全局键盘事件

.net - 如何在 FileSavePicker 中接受任何文件类型?

c++ - 支持的 API 测试失败 (C++/CX)

c# - 雾与 c# 统一

c# - 使用 ASP.net 发送电子邮件

c# - 寻找一种更好的方法来使用 C# 组织 xml 流

具有模糊背景的 C# 对话框窗体

Windup 工具中的 Java 到 Wsdl 映射