title: how to send binary data within an xml string
body: <p>I want to send a binary file to .net c# component in the following xml format</p>
  
  <pre><code>&lt;BinaryFileString fileType='pdf'&gt;
      &lt;!--binary file data string here--&gt;
  &lt;/BinaryFileString&gt;
  </code></pre>
  
  <p>In the called component I will use the above xml string and convert the binary string received within the BinaryFileString tag, into a file as specified by the filetype='' attribute. The file type could be doc/pdf/xls/rtf</p>
  
  <p>I have the code in the calling application to get out the bytes from the file to be sent. How do I prepare it to be sent with xml tags wrapped around it? I want the application to send out a string to the component and not a byte stream. This is because there is no way I can decipher the file type [pdf/doc/xls] just by looking at the byte stream. Hence the xml string with the filetype attribute. Any ideas on this?</p>
  
  <p>method for extracting Bytes below</p>
  
  <pre><code>   FileStream fs = new FileStream(_filePath, FileMode.Open, FileAccess.Read);
     using (Stream input = fs)
     {
        byte[] buffer = new byte[8192];
        int bytesRead;
        while ((bytesRead = input.Read(buffer, 0, buffer.Length)) &gt; 0)
        {}
     }
     return buffer;
  </code></pre>
  
  <p>Thanks.</p>
  
  <h2>Edit:</h2>
  
  <p>Just to clarify why I am using an xml string rather than setting properties on my component. Actually my calling app is trying to simulate how Siebel will call my component. 
  <a href="http://download.oracle.com/docs/cd/E05553_01/books/eScript/eScript_JSReference244.html#wp1014380" rel="noreferrer">http://download.oracle.com/docs/cd/E05553_01/books/eScript/eScript_JSReference244.html#wp1014380</a>
  Im not sure if Siebel can set my components properties as I need it to. So Im working on the angle of it sending the data in xml. </p>