繁体   English   中英

MessageBodyMember 命名空间覆盖 WSDL 中的 DataContract 命名空间

[英]MessageBodyMember namespace overrides DataContract namespace in WSDL

我有以下消息合同:

[MessageContract(IsWrapped = false)]
public class fooResponse
{
    [MessageBodyMember(Namespace = "http://www.demo.com/serviceSchemaTypes-v1.4/")]
    public commonReturnType fooResponse1 { get; set; }
}

commonReturnType是下面的DataContract

[DataContract(Namespace = "http://www.demo.com/serviceSchema-v1.4/")]
public class commonReturnType
{
    [DataMember]
    public returnCode returnCode { get; set; }

    [DataMember]
    public string errorMessage { get; set; }
}

生成的 WSDL 文件将commonReturnType的命名空间覆盖为public commonReturnType fooResponse1 { get; set; } public commonReturnType fooResponse1 { get; set; } public commonReturnType fooResponse1 { get; set; } 将生成的 WSDL 文件导入另一个项目后, commonReturnType如下所示:

[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.demo.com/serviceSchemaTypes-v1.4/")]
public partial class commonReturnType

在这里,命名空间应该是http://www.demo.com/serviceSchema-v1.4/ 为什么命名空间在这里发生变化,我该如何解决这个问题?

您错误的原因可能是您设置了此属性:

IsWrapped = false

可以参考官方文档: Using Message Contracts to make changes。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM