How can i send a List<Stream> as part of WCF messageContract

One07k-4914 101 Reputation points
2023-03-02T12:00:54.0933333+00:00

Hi All,

I want to send List<Stream> through wcf service.My contract is something below.

    [MessageContract]
    public class ResponseData 
    {
        /// <summary>
        /// 
        /// </summary>
        [MessageHeader]
        public CustomResult Result { get; set; }
        /// <summary>
        /// Stream Data
        /// </summary>
        [MessageBodyMember]
        public List<VolumeInfo> Info { get; set; }
    }

    /// <summary>
    /// 
    /// </summary>
    [MessageContract]
    public class VolumeInfo
    {
        /// <summary>
        /// 
        /// </summary>
        [MessageHeader]
        public int Index { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [MessageBodyMember]
        public Stream Data { get; set; }
    }
	
API:
	[OperationContract]
	public ResponseData GetVolumeDeta();

Is there any way to do that?

Thanks in advance.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,457 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,375 questions
{count} votes

Accepted answer
  1. QiYou-MSFT 4,306 Reputation points Microsoft Vendor
    2023-03-03T06:19:02.68+00:00

    Hi @la07k-4914

    Generally, the transmission of List data is transmitted using XML. You can convert your stream to a byte array and use the XmlSerializer class to transport it.

    Document1

    Best Regards

    Qi You


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.


0 additional answers

Sort by: Most helpful