2

I am trying to use the NBR API for my webex site. When I run a downloadNBRStorageFile SOAP request it responds with the webex recording in a stream.

WebResponse response = request.GetResponse();
Stream responseStream = response.GetResponseStream();

When I pull the stream out of the response in C# the stream and write it to a file. The stream and file contain additional header details causing the file to not be able to open in the Network Based Recording Player.

When I inspect the downloaded file from the API in notepad it looks like this:

------=_Part_281_1815085984.1458150816433 Content-Type: text/xml; charset=UTF-8 Content-Transfer-Encoding: binary Content-Id: <0CA08FF0D94F4292B948DF640C1DD4E2>

------=_Part_281_1815085984.1458150816433 Content-Type: application/octet-stream Content-Transfer-Encoding: binary Content-Id:

Bob’s Personal Room-20160108 1435-1.arf 648735 false ------=_Part_281_1815085984.1458150816433 Content-Type: application/octet-stream Content-Transfer-Encoding: binary Content-Id:

[1] èËæV¬æ d ….random characters (.arf file data)


1) How in C# can I save just the file data so that when I save it as file.arf I will be able to open it

 WebResponse response = request.GetResponse();
        //  HttpWebResponse response = (HttpWebResponse)request.GetResponse();



        Stream responseStream = response.GetResponseStream();
        MemoryStream memoryStream = new MemoryStream();

        String test = responseStream.ToString();


        int count = 0;

        do
        {
            count = responseStream.Read(buffer, 0, buffer.Length);
            memoryStream.Write(buffer, 0, count);

            if (count == 0)
            {
                break;
            }
        }
        while (true);

        result = memoryStream.ToArray();


        FileStream fs = new FileStream("c:\\file5.arf", FileMode.OpenOrCreate, FileAccess.ReadWrite);

        fs.Write(result, 0, result.Length);

        fs.Close();
        memoryStream.Close();
        responseStream.Close();

Any assistance on this would be much appreciated as I have been stuck on this for a couple days. I'm assuming I have to parse through the multipart stream, to save just the actual file data, but that is where I am stuck at.

  • what i recommend is, since the response is soap payload, you may have to analyze the response and debug which part of the payload you are interested to save. Later use any xml api to load and save it. – Gomes Mar 22 '16 at 15:16
  • @Gomes Thanks Gomes for the feedback. I can't seem to get the xml payload out of the response...I've tried to debug in VS and see what attribute it is coming into, but I don't see it in the response or response stream. I know it is there though because when that stream is written to a file, the file contains all that data. – user6099097 Mar 23 '16 at 11:30
  • can you try this StreamReader responseStream =new StreamReader(response.GetResponseStream()); result = responseStream.ReadToEnd(); then you can use XmlDocument() class to parse or save it. – Gomes Mar 23 '16 at 16:55

0 Answers0