我创建了一个像这样的 WebService:
[WebService(Namespace = "http://ns")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class GroupManagerService : WebService
{
public GroupManagerService()
{
}
[WebMethod]
public bool MyMethod(string loginname, string country)
{
// code here...
}
}
是否可以在不连接到正在运行的服务的情况下为此代码生成WSDL文件?我搜索并找到了关于SvcUtil.exe和wsdl.exe的信息,但这些仅适用于从正在运行的Web服务检索WSDL。
(对于Java,有一个名为java2wsdl的工具,是否有相当于C#的工具?)
:更新:
这个问题的背景是,我想向SharePoint添加新的CustomWebService,该服务应使用WSPBuilder在SharePoint的_vti_bin文件夹中部署。
请参见我的帖子在SharePoint.SE上。
并且我想自动生成(使用msbuild命令)必须放置在_vti_bin文件夹中的'MyServicewsdl.aspx'和'MyServicedisco.wsdl'。
也许我错过了一些东西?
svcutil.exe的输出为:
bin\Debug>SvcUtil.exe MyWebService.dll
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152]
Copyright (c) Microsoft Corporation. All rights reserved.
Generating metadata files...
Warning: No metadata files were generated. No service contracts were exported.
To export a service, use the /serviceName option. To export data contracts, spe
cify the /dataContractOnly option. This can sometimes occur in certain security
contexts, such as when the assembly is loaded over a UNC network file share. If
this is the case, try copying the assembly into a trusted environment and runnin
g it.