您好,
WCF 中数据/服务契约(Contract)的默认命名空间是 "http://tempuri.org/"
.通过设置 ServiceContract.Namespace
和 ServiceBehavior.Namespace
我们可以获得自定义命名空间。然而,我对此有一些疑问:
http://
命名空间还是我可以将其命名为相同的 CLS 命名空间? 最佳答案
问题 1. 命名空间可以是任何东西。人们通常使用某种形式的 URI,但它不必指向实际的网页。人们通常会在命名空间中使用版本标识符,但没有关于您应该做什么的规则。
问题 2. 见上文。
问题 3. 您可以为所有合约设置命名空间,如下所示:
// This overrides the standard namespace mapping for all contracts
// in Contoso.CRM.
[assembly: ContractNamespace("http://schemas.example.com/crm",
ClrNamespace = "Contoso.CRM")]
namespace Contoso.CRM
{
// The namespace is overridden to become:
// http://schemas.example.com/crm.
// But the name is the default "Customer".
[DataContract]
public class Customer
{
// Code not shown.
}
}
你可以看看这个MSDN Article想要查询更多的信息
关于WCF 契约(Contract)和命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11408582/