微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

MessageHeader 属性未显示 - wcf 服务

如何解决MessageHeader 属性未显示 - wcf 服务

我的 WCF 服务中有一个带有 MessageContractMessageHeader 属性MessageBodyMember 类。但是,当我检查 wsdl 时它是可见的,当我添加到我的 uwp 时应用程序只有 MessageBodyMember 是可见的。我检查了添加服务引用后添加reference.cs,但 MessageHeader 在其中不可见。

服务合同

[MessageContract]
public class RemoteFileInfo : Idisposable
{
    [MessageHeader(MustUnderstand = true)]
    public string FileName;

    [MessageHeader(MustUnderstand = true)]
    public long Length;

    [MessageBodyMember(Order = 1)]
    public System.IO.Stream FileByteStream;

    public void dispose()
    {
         if (FileByteStream != null)
        {
            FileByteStream.Close();
            FileByteStream = null;
        }
    }
}

当我向 UWP 应用程序添加服务引用时

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel","4.0.0.0")]
[System.ServiceModel.MessageContractAttribute(WrapperName="RemoteFileInfo",WrapperNamespace="http://tempuri.org/",IsWrapped=true)]
public partial class RemoteFileInfo {
    
    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/",Order=0)]
    public byte[] FileByteStream;
    
    public RemoteFileInfo() {
    }
    
    public RemoteFileInfo(byte[] FileByteStream) {
        this.FileByteStream = FileByteStream;
    }
}

WSDL

<wsdl:message name="RemoteFileInfo">
<wsdl:part name="parameters" element="tns:RemoteFileInfo"/>
</wsdl:message>
<wsdl:message name="RemoteFileInfo_Headers">
<wsdl:part name="FileName" element="tns:FileName"/>
<wsdl:part name="Length" element="tns:Length"/>
</wsdl:message>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。