【问题标题】:Create a NETMF service and generate a WSDL file for it创建一个 NETMF 服务并为其生成一个 WSDL 文件
【发布时间】:2016-01-31 11:25:51
【问题描述】:

我们要创建一个 NETMF web service that lives on a device

我们已阅读MSDN Implementing Web Services on Your Devices。它解释了Generating Service Model Code Using MfSvcUtil,它假定我们已经有一个 WSDL 文件。

我们首先如何生成 WSDL 文件?

【问题讨论】:

    标签: c# web-services wsdl .net-micro-framework


    【解决方案1】:

    回答

    在 C# 中创建一个 NETMF 服务并从中生成 WSDL。

    步骤

    首先,使用 DPWS 安装 NEFMF。我们使用来自NETMF on Codeplex 的 NETMF 4.3 和 DPWS。这也可能适用于NETMF 4.4 or later from GitHub

    其次,将 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 文件。万岁!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-07
      • 1970-01-01
      • 1970-01-01
      • 2021-03-26
      • 1970-01-01
      • 2016-10-05
      • 2022-01-13
      • 1970-01-01
      相关资源
      最近更新 更多