问题描述
|
在为该命名空间生成了什么svcutil之后,我对我的服务合同命名空间有疑问。
设置如下:
[ServiceContract(Name=\"Colors\",Namespace=\"http://colors.com/colors/2011/05\")]
使用svutil生成的代理代码创建了以下名称空间:
namespace colors.com.colors._2011._05
上面的问题是,我看不到很多类似于上面的名称空间,尤其是_2011._05的日期部分,这使我怀疑这是否是在服务合同上设置名称空间的正确方法。
解决方法
这很大程度上取决于您的服务合同版本控制方案,但是在某些情况下,许多标准规范确实在名称空间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)