question

RohitGupta-0830 avatar image
0 Votes"
RohitGupta-0830 asked TheobaldDu-MSFT answered

MessageHeader Attribute is not showing up - wcf service

I have a MessageContract class with MessageHeader and MessageBodyMember properties in my WCF service.It is visible when I check the wsdl however, when I add to my uwp application only the MessageBodyMember is visible. I have checked the reference.cs which is added after I add service reference and MessageHeader is not visible in that.

Contract in service

 [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;
         }
     }
 }

When I add service reference to UWP application

 [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>



dotnet-csharpwindows-uwpwindows-wcf
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TheobaldDu-MSFT avatar image
0 Votes"
TheobaldDu-MSFT answered

Hi, @RohitGupta-0830 , Try to remove the reference and add it again. Which way do you choose to add a wcf service reference to the UWP client? The easiest way is to add the service reference directly and then call the wcf service. For how to add a service reference, you can refer to Add Service Reference in Visual Studio.



If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best regards,
Theobald Du


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.