How to interpret file returned from web service task
I have created a simple SSIS package containing a web service task. The web service task calls an asp.net web service that returns a binary stream representing a two line input text file as follows: This is Line 1This is line 2The output of the web service ends up looking lilke this:<?xml version="1.0" encoding="utf-16"?><base64Binary>VGhpcyBpcyBMaW5lIDENClRoaXMgaXMgbGluZSAyDQo=</base64Binary>The web service uses a FileStream to stream the file information to the output of the web service. Looks like the web service (an asp.net web service) is encoding the information in base64 and then wrapping that inside of the xml envelope in an element named <base64Binary>. The webmethod looks like this: [ WebMethod]\public Byte[] GetFile(){// read excel file into stream readerstring strdocPath;strdocPath = "C:\\TestInputFile.txt";FileStream objfilestream = new FileStream(strdocPath, FileMode.Open, FileAccess.Read);int len = (int)objfilestream.Length;Byte[] documentcontents = new Byte[len];objfilestream.Read(documentcontents, 0, len);objfilestream.Close();return documentcontents; } After running my SSIS package, i end up with a file being created on my SSIS server, however it's in the xml format shown above. What i really want is to recreate a file that looks exactly like the input text file. Looks like i will need to (in my ssis package) somehow read the data from the xml file and decode it from base 64 back to ascii format and then write that out to a file on the SSIS server ? Is there an easier way to go about this without having to manipulate the output of the web service. Can i either program my web service not to encode the data (just send it as binary) and not wrap it in the XML tags, or conversely can i get my ssis package to smartly unpack the information and recreate the file.
February 13th, 2010 3:11am

Hi Elitz,In Web Service Task Editor, there is another option for storing the returned value in a variable. (Create a package level variable: Choose Your package when creating a Variable.) Then drag and drop a Script Task in Control Flow, include your variable in script task convert base64 binary to Ascii by code and do the rest as you wish.Best RegardsOnur BI and ERP Consultant @ Nexum Bogazici Personal Blog: http://www.ssisnedir.com/blog - If it is, Please dont forget to mark as answered.
Free Windows Admin Tool Kit Click here and download it now
February 13th, 2010 11:00pm

Hi, I have a similar problem. When i make the Package Variable as suggested - I am not able to select the type byte og base64. If I select string I get the error: An object with type system.string cannot be converted to type system.byte[]. Can you give a littele bit more info on how to convert the variable to the correct type? Thanks, Jesper W
June 15th, 2011 8:21am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics