简体   繁体   中英

Using WSDL web service in Windows 8 store C# application: The base class or interface could not be resolved

I have written a simple WSDL web service with Java in Eclipse. Here is the Java code prototype of the service:

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

I have generated a proxy class for this WSDL service using the Microsoft wsdl.exe tool and make it a dll by using following commands from the Developer Command Prompt Visual Studio 2012:

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

In my Windows 8 Store application, I then added a reference to this dll, then added following code in MainPage.xaml.cs:

WriteAnnouncementService was = new WriteAnnouncementService();

When I tried to run the application, I got this error:

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

I then added a reference to System.Web.Service and rebuilt the application. Now I am getting the following error:

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

Is there a reason you generate the proxy with wsdl.exe?

I am not an expert of the Windows 8 store subset of the bcl but I would recommend using the svcutil to generate the proxy from known wsdl as the generated proxy supports the newer web services subsystem. The generated proxies inherits from different classes in the base class library. To me it is more likely that the newer subsystem will seamlessly work in a constrained environment.

Adding service reverence via "Add Service Reference" solved the problem. 在此输入图像描述

在此输入图像描述

But I have an other problem with the generated reference.cs file. There are multiple errrors about ambigous calls.

The call is ambiguous between the following methods or properties: 'GyteKiosk.ServiceReference1.WriteAnnouncementClient.ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint, System.ServiceModel.Description.ClientCredentials)' and 'GyteKiosk.ServiceReference1.WriteAnnouncementClient.ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint, System.ServiceModel.Description.ClientCredentials)' Reference.cs 115 13

UPDATE!

I have solved the ambigous call promlem too. Step by step solution for ambigous call:

  1. My service class name was "WriteAnnouncement" and the service method name was "vriteAnnouncement". Changed method name to just "write".
  2. Recreated Web Service in Eclipse without any test client.
  3. Took the WSDL file and placed in project folder.
  4. Deleted previously added service reference and readded service reference. Gave neme to service reference as "WAServRef"

To use service in project:

  1. Add using GyteKiosk.WAServRef; to page code whic you will use service in.
  2. Call your service where you want to use:

      WriteAnnouncementClient wac = new WriteAnnouncementClient(); Task<GyteKiosk.WAServRef.writeResponse> wres = wac.writeAsync("Gyte Kiosk", "Gyte Kiosk"); String result = wres.Result.Body.writeReturn; this.pageTitle.Text = result; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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