Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Streaming the response of type byte[]

Streaming the response of type byte[]

Scheduled Pinned Locked Moved C#
xmljson
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NarVish
    wrote on last edited by
    #1

    I'm trying to write a client for a webservice method, which responds with byte[] I would like to stream it because byte[] will be failed if there is large file. I changed Transfer Mode and Encoding to Streamed and Mtom respectively. I commented XMLTypeAttribute declaration in reference file for the byte[] class. Please correct the code. Reference.cs

    ///
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4016")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    //[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http//tempuri.org/sample/types")]
    public partial class echoBinaryDataResponse : object, System.ComponentModel.INotifyPropertyChanged {

        private byte\[\] paramField;
        
        /// 
        \[System.Xml.Serialization.XmlElementAttribute(DataType = "base64Binary", Order = 0)\]
        public byte\[\] param
        {
            get {
                return this.paramField;
            }
            set {
                this.paramField = value;
                this.RaisePropertyChanged("param");
            }
        }
    

    My client call -----------

    ServiceReference1.echoBinaryData echo = new ServiceReference1.echoBinaryData();
    MemoryStream str = new MemoryStream(myByteArray);
    echo.param = str;
    ServiceReference1.echoBinaryDataResponse echoResp = new ServiceReference1.echoBinaryDataResponse();
    ServiceReference1.SamplePortTypeClient sample = new ServiceReference1.SamplePortTypeClient();
    sample.echoBinaryData(echo);-----getting exception here

    Note: myByteArray is of type byte[];

    L 1 Reply Last reply
    0
    • N NarVish

      I'm trying to write a client for a webservice method, which responds with byte[] I would like to stream it because byte[] will be failed if there is large file. I changed Transfer Mode and Encoding to Streamed and Mtom respectively. I commented XMLTypeAttribute declaration in reference file for the byte[] class. Please correct the code. Reference.cs

      ///
      [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4016")]
      [System.SerializableAttribute()]
      [System.Diagnostics.DebuggerStepThroughAttribute()]
      [System.ComponentModel.DesignerCategoryAttribute("code")]
      //[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http//tempuri.org/sample/types")]
      public partial class echoBinaryDataResponse : object, System.ComponentModel.INotifyPropertyChanged {

          private byte\[\] paramField;
          
          /// 
          \[System.Xml.Serialization.XmlElementAttribute(DataType = "base64Binary", Order = 0)\]
          public byte\[\] param
          {
              get {
                  return this.paramField;
              }
              set {
                  this.paramField = value;
                  this.RaisePropertyChanged("param");
              }
          }
      

      My client call -----------

      ServiceReference1.echoBinaryData echo = new ServiceReference1.echoBinaryData();
      MemoryStream str = new MemoryStream(myByteArray);
      echo.param = str;
      ServiceReference1.echoBinaryDataResponse echoResp = new ServiceReference1.echoBinaryDataResponse();
      ServiceReference1.SamplePortTypeClient sample = new ServiceReference1.SamplePortTypeClient();
      sample.echoBinaryData(echo);-----getting exception here

      Note: myByteArray is of type byte[];

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      NarVish wrote:

      sample.echoBinaryData(echo);-----getting exception here

      What exception?

      Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

      N 1 Reply Last reply
      0
      • L Lost User

        NarVish wrote:

        sample.echoBinaryData(echo);-----getting exception here

        What exception?

        Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

        N Offline
        N Offline
        NarVish
        wrote on last edited by
        #3

        Sorry, forgot to add the exception Exception:There was an error reflecting 'echoBinaryData'.

        L 1 Reply Last reply
        0
        • N NarVish

          Sorry, forgot to add the exception Exception:There was an error reflecting 'echoBinaryData'.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You need to trap this with your debugger or add some more code to identify the inner exception. "There was an error" tells us nothing.

          Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

          N 1 Reply Last reply
          0
          • L Lost User

            You need to trap this with your debugger or add some more code to identify the inner exception. "There was an error" tells us nothing.

            Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

            N Offline
            N Offline
            NarVish
            wrote on last edited by
            #5

            Irrespective of above exceptions, can u just guide me to stream byte array (which comes as response of webmethod)

            L 1 Reply Last reply
            0
            • N NarVish

              Irrespective of above exceptions, can u just guide me to stream byte array (which comes as response of webmethod)

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Sorry, not something I have much experience of. Try the articles section or the MSDN documentation.

              Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

              N 1 Reply Last reply
              0
              • L Lost User

                Sorry, not something I have much experience of. Try the articles section or the MSDN documentation.

                Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

                N Offline
                N Offline
                NarVish
                wrote on last edited by
                #7

                I found this article and it soved my issue. Thanks for your replies http://blogs.msdn.com/b/carlosfigueira/archive/2011/03/25/wcf-streaming-inside-data-contracts.aspx[^]

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups