创建 NETMF 服务并为其生成 WSDL 文件
Create a NETMF service and generate a WSDL file for it
我们要创建一个 NETMF web service that lives on a device。
我们已经阅读了MSDN Implementing Web Services on Your Devices. It explains Generating Service Model Code Using MfSvcUtil,它假定我们已经有一个 WSDL 文件。
首先我们如何生成 WSDL 文件?
回答
在 C# 中创建 NETMF 服务并从中生成 WSDL。
步骤
首先,使用 DPWS 安装 NEFMF。我们将 NETMF 4.3 与来自 NETMF on Codeplex. This might also work with NETMF 4.4 or later from GitHub.
的 DPWS 一起使用
其次,将 C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Tools
添加到您的 PATH 中。这是访问 MFSvcUtil
.
的便捷方式
第三步,创建一个带有服务的新 NETMF 项目。这是一个非常简单的。您将需要引用 MFWsStack.dll
,因为它包含 Ws.ServiceModel
命名空间。
using Ws.ServiceModel;
namespace FooService
{
[ServiceContract]
public interface FooService
{
[OperationContract]
void Start();
}
}
四、构建项目
第五,运行以下(在PowerShell中)创建WSDL文件。
> $projectRoot = "C:\FooService\";
> $svcAssembly = ".\bin\Debug\FooService.dll";
> $library = "C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le";
> $destinationDir = ".\temp";
> $destinationFile = "FooService.wsdl";
> cd $projectRoot;
> New-Item -type dir $destinationDir;
> mfsvcutil $svcAssembly /R:$library /D:$destinationDir /O:$destinationFile
ServiceContract = FooService
Operation Name = Start
Writing FooService Service Description to: .\temp\FooService.wsdl
Processing complete.
在上面的脚本中,library
是包含MFWsStack.dll
的目录,这是我们项目唯一的外部引用。该脚本在 C:\FooService\temp\FooService.wsdl
中创建 WSDL 文件。万岁!
我们要创建一个 NETMF web service that lives on a device。
我们已经阅读了MSDN Implementing Web Services on Your Devices. It explains Generating Service Model Code Using MfSvcUtil,它假定我们已经有一个 WSDL 文件。
首先我们如何生成 WSDL 文件?
回答
在 C# 中创建 NETMF 服务并从中生成 WSDL。
步骤
首先,使用 DPWS 安装 NEFMF。我们将 NETMF 4.3 与来自 NETMF on Codeplex. This might also work with NETMF 4.4 or later from GitHub.
的 DPWS 一起使用其次,将 C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Tools
添加到您的 PATH 中。这是访问 MFSvcUtil
.
第三步,创建一个带有服务的新 NETMF 项目。这是一个非常简单的。您将需要引用 MFWsStack.dll
,因为它包含 Ws.ServiceModel
命名空间。
using Ws.ServiceModel;
namespace FooService
{
[ServiceContract]
public interface FooService
{
[OperationContract]
void Start();
}
}
四、构建项目
第五,运行以下(在PowerShell中)创建WSDL文件。
> $projectRoot = "C:\FooService\";
> $svcAssembly = ".\bin\Debug\FooService.dll";
> $library = "C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le";
> $destinationDir = ".\temp";
> $destinationFile = "FooService.wsdl";
> cd $projectRoot;
> New-Item -type dir $destinationDir;
> mfsvcutil $svcAssembly /R:$library /D:$destinationDir /O:$destinationFile
ServiceContract = FooService
Operation Name = Start
Writing FooService Service Description to: .\temp\FooService.wsdl
Processing complete.
在上面的脚本中,library
是包含MFWsStack.dll
的目录,这是我们项目唯一的外部引用。该脚本在 C:\FooService\temp\FooService.wsdl
中创建 WSDL 文件。万岁!