【发布时间】:2018-02-20 05:36:45
【问题描述】:
在 Linux 上,如何编译和执行holidayclient.cs? using 导入当然是 required。还有namespace?
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ ls
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ wsdl http://api.google.com/GoogleSearch.wsdl
Web Services Description Language Utility
Mono Framework v4.0.30319.42000
Error: ThereWasAnErrorDownloading0
Stack:
at System.Web.Services.Discovery.DiscoveryClientProtocol.Download (System.String& url, System.String& contentType) [0x000b1] in <df933ee897464fb99338a340b9d5761d>:0
at System.Web.Services.Discovery.DiscoveryClientProtocol.DiscoverAny (System.String url) [0x0000f] in <df933ee897464fb99338a340b9d5761d>:0
at (wrapper remoting-invoke-with-check) System.Web.Services.Discovery.DiscoveryClientProtocol:DiscoverAny (string)
at Mono.WebServices.Driver.Run (System.String[] args) [0x000f5] in <24b8cb9db67d4a19a4db9642439f119f>:0
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ wsdl http://holidaywebservice.com/HolidayService_v2/HolidayService2.asmx
Web Services Description Language Utility
Mono Framework v4.0.30319.42000
Writing file 'HolidayService2.cs'
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ mcs /target:library HolidayService2.cs -r:System.Web.Services
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ ls
HolidayService2.cs HolidayService2.dll
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ nano holidayclient.cs
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ cat holidayclient.cs
using System;
class HolidayClient
{
public static void Main (string [] args)
{
HolidayService2 holiday = new HolidayService2 ();
String response = holiday.foo ("hmm");
Console.WriteLine(response);
}
}
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ mcs holidayclient.cs
holidayclient.cs(7,9): error CS0246: The type or namespace name `HolidayService2' could not be found. Are you missing an assembly reference?
holidayclient.cs(9,27): error CS0841: A local variable `holiday' cannot be used before it is declared
Compilation failed: 2 error(s), 0 warnings
thufir@dur:~/wsdl$
不确定在MonoDevelop 中单击哪些按钮,因此正在使用 CLI。
参考:
http://www.mono-project.com/archived/consuming_a_webservice/
http://holidaywebservice.com/HolidayService_v2/HolidayService2.asmx?op=GetHolidayDate
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0246
【问题讨论】:
-
嘿,您能否提供一些关于您想要实现的目标的背景信息?是否要添加对 Web 服务的引用并调用它?
-
添加对已编译 dll 的引用,这是一个 Web 服务,然后调用库上的方法。是的@muszeo。 CLI 或 monodevelop (Linux)。
-
好的,我支持你。一旦您生成了服务客户端 dll (HolidayService2.dll),那么理论上您应该能够将其添加为 MonoDevelop 中项目的引用并调用它;这将通过
/ References 右键单击 Edit References... 对话 .NET Assembly 选项卡。我会在下面写一个答案。
标签: dll namespaces mono .net-core monodevelop