我在 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/