MessageHeader 属性未显示 - wcf 服务

时间:2021-05-21 14:06:22

标签: c# 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>

0 个答案:

没有答案