【问题标题】:WCF add attribute to soap bodyWCF 将属性添加到肥皂体
【发布时间】:2015-03-31 20:13:09
【问题描述】:

我需要为 body 元素添加一个属性。我该怎么做?

<soapenv:Body wsu:Id="body">

我正在使用 XmlSerializerFormat。我的代码:

f[ServiceContract(Namespace = "http://TSUtoMFC")]
[XmlSerializerFormat]
public interface IService
{
    [XmlSerializerFormat]
    [OperationContract]
    ResponseType SampleTestSmev();

}

    [MessageContract]
    [XmlSerializerFormat]
    public class ResponseType
    {
        [MessageHeader]
        public SecurityType Security = new SecurityType();
        [MessageHeader]
        public smevheader header = new smevheader();
        [MessageBodyMember(Namespace = "http://smev.gosuslugi.ru/rev120315")]
        public MessageType Message = new MessageType();
        [MessageBodyMember(Namespace = "http://smev.gosuslugi.ru/rev120315")]
        public MessageDataType MessageData = new MessageDataType();

}

【问题讨论】:

  • 你有没有尝试过?如果您分享您的尝试,您将获得更多帮助。
  • 将[XmlAttribute] 添加到您的body 类的Id 属性中。除此之外,请尝试展示您到目前为止所做的事情。
  • @dbc 我无法访问 body 元素,因为它是肥皂信封元素

标签: c# xml web-services wcf


【解决方案1】:

您可以使用IDispatchMessageInspector 启用对入站和出站消息的自定义修改。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-14
    • 2013-09-22
    • 2012-04-25
    • 1970-01-01
    • 2018-04-12
    • 1970-01-01
    相关资源
    最近更新 更多