【问题标题】:Is my service contract namespace right?我的服务合同命名空间是否正确?
【发布时间】:2011-05-26 14:20:49
【问题描述】:

在 svcutil 为命名空间生成之后,我对我的服务合同命名空间有疑问。

设置如下:

[ServiceContract(Name="Colors", Namespace="http://colors.com/colors/2011/05")]

使用 svutil 生成的代理代码创建了以下命名空间:

namespace colors.com.colors._2011._05

我在上面遇到的问题是,我没有看到很多看起来像上面的命名空间,尤其是 _2011._05 的日期部分,这让我怀疑这是否是在服务合同上设置命名空间的正确方法。

【问题讨论】:

    标签: wcf


    【解决方案1】:

    这在很大程度上取决于您的服务合同版本控制方案是什么,但在某些情况下,许多标准规范确实在命名空间 URI 中包含一些日期组件,这很好。

    我同意默认生成的代码命名空间看起来很难看,但无论您选择哪种方案,这几乎总是如此:)。请记住,您可以在运行 svcutil 时使用 /namespace 开关覆盖它:

     /namespace:<string,string>         - A mapping from a WSDL or XML Schema
                                          targetNamespace to a CLR namespace. Using
                                          the '*' for the targetNamespace maps all
                                          targetNamespaces without an explicit
                                          mapping to that CLR namespace. Default:
                                          derived from the target namespace of the
                                          schema document for Data Contracts. The
                                          default namespace is used for all other
                                          generated types. (Short Form: /n)
    

    【讨论】:

    • 感谢命名空间切换提示。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-28
    • 1970-01-01
    • 2010-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多