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 web service that returns a binary stream representing a two line input text file as follows:
    This is Line 1
    This is line 2

    The output of the web service ends up looking lilke this:
    <?xml version="1.0" encoding="utf-16"?>

    The web service uses a FileStream to stream the file information to the output of the web service. Looks like the web service (an 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:


    public Byte[] GetFile(){
    // read excel file into stream reader
    string strdocPath;
    strdocPath =
    FileStream objfilestream = new FileStream(strdocPath, FileMode.Open, FileAccess.Read);
    int len = (int)objfilestream.Length;
    Byte[] documentcontents = new Byte[len];
    objfilestream.Read(documentcontents, 0, len);
    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.
    sábado, 13 de febrero de 2010 0:11


Todas las respuestas

  • 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 Regards

    BI and ERP Consultant @ Nexum Bogazici Personal Blog: - If it is, Please dont forget to mark as answered.
    • Propuesto como respuesta Onur Omer Ozturk sábado, 13 de febrero de 2010 20:02
    • Marcado como respuesta Zongqing Li viernes, 19 de febrero de 2010 7:17
    sábado, 13 de febrero de 2010 20:00
  • 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?


    Jesper W

    miércoles, 15 de junio de 2011 12:19